View Single Post
  #8 (permalink)  
Old 04-11-2008, 04:55 PM
Elemental's Avatar
Elemental Elemental is offline
Senior Member
 
Join Date: Jul 2007
Posts: 122
Default

The init() method of any controller is only run once per controller, regardless of how many actions are run in that controller per request. However if you extend Zend_Controller_Action and put you code in init() then you'll have to call parent::init() on every controller that uses your new controller class.

What you could do is set a flag in session or just the registry that indicates this logic has already run, then check to see if its set before running the logic. This would make a plugin more appropriate.

Code:
$runOnce = Zend_Registry::get('runOnce');
if (!is_null($runOnce)){
    //do something cool, but only once!
}
Reply With Quote