ZF-1130: view suffix overridden when extending Zend_Controller_Action :: initView
Description
When overriding Zend_Controller_Action :: initView the viewSuffix will be overriden if you change it within the initView method.
Take the following code:
<?php
require_once 'Zend/Controller/Action.php';
class Sanmax_Controller_Action extends Zend_Controller_Action
{
public function initView()
{
if (null !== $this->view) {
return;
}
require_once 'Sanmax/View/Smarty.php';
$config = Zend_Registry::get('config');
$this->view = new Sanmax_View_Smarty($config->smarty->asArray());
$this->viewSuffix = 'html';
return $this->view;
}
}
Zend_Controller_Action will request the viewSuffix before it calls initView, and thus the viewSuffix will be reset to 'phtml'
Comments
Posted by Andries Seutens (andries) on 2007-03-24T12:59:55.000+0000
This patch simply changes to variables from place, and fixes the issue. Please consider it.
Posted by Darby Felton (darby) on 2007-03-28T09:38:36.000+0000
Assigning to [~matthew].
Posted by Matthew Weier O'Phinney (matthew) on 2007-04-02T11:38:07.000+0000
Patch applied in revision 4307.
One note: Since $viewSuffix is a public property, this could have been achieved by simply setting the class property:
instead of overriding it in initView().
Posted by Ryan Lange (ryan.lange) on 2010-02-11T12:25:33.000+0000
Matthew Weier O'Phinney wrote:
For anyone, like me, that ran across this while looking for a solution to their "controller action ignores custom viewSuffix" problem, Matthew's comment is unfortunately untrue. See ZF-5301.