View Single Post
  #3 (permalink)  
Old 07-11-2008, 11:47 AM
smsiebe smsiebe is offline
Junior Member
 
Join Date: Oct 2007
Location: Augusta, GA
Posts: 9
Default

A little foundational first....

init() is called by Zend_Controller_Action from the constructor method so you can add functionalities to the initialization of your controller class (done so you don't have to overload the parent __construct() magic method and have to do a parent::__construct() call). So, init() should be treated as if it was actually __construct().

For what you are trying to achieve, I would suggest that you do not assign the footer in the init() method. If you want to have the footer included by default, and be able to toggle it off if necessary (such as with the showCatAction() method), I would suggest you assign you footer placeholder a bit later on in the workflow, such as in postDispatch().

PHP Code:
class IndexController extends Zend_Cotroller_Action
{

      
/**
       * toggle footer rendering
       *
       * @var boolean
       */
       
protected $_renderFooter TRUE;

      function 
indexAction()
      {
           
// my code
      
}


      function 
showCatAction()
      {
           
$this->_noFooter();
      }

      public function 
postDispatch ()
      {
           if (
$this->_renderFooter === TRUE) {
               
//note, the footer is TRUE by default
               
$response -> insert('footer'$this->view->render('footer.phtml'));
           }
      }

      
/**
       * turn footer rendering off
       *
       * @return void
       */
       
protected function _noFooter () {
            
$this->_renderFooter FALSE;
            return;
       }


Hope this helps.

Steve
__________________
Steve Siebert
Zend Certified Engineer
General Dynamics IT
www.get-dev.com
Reply With Quote