View Single Post
  #2 (permalink)  
Old 10-02-2007, 08:05 AM
khelo khelo is offline
Junior Member
 
Join Date: Oct 2007
Posts: 5
Thumbs up

Plugins are not so difficult to use. When you implement a plugin , you just need to extend Zend_Controller_Plugin_Abstract , implementing the method you're interested in ( each has a suggestive name , for example dispatchLoopStartup)
PHP Code:
//somewhere 
class FooPlugin extends  Zend_Controller_Plugin_Abstract 
{
     
    public function 
postDispatch(Zend_Controller_Request_Abstract $request)
    {
        
$response =  $this->getResponse();
        
$view Zend_Controller_Front::getInstance()->getHelper('viewRenderer')->view;
        
$view->foo 'something';
        
$response->prepend('header',$view->render('yourheader.phtml');
    }


in your bootstrap :
PHP Code:
//......
$controller Zend_Controller_Front::getInstance();
$controller->registerPlugin('FooPlugin');
//etc 
I just gave you a simple example on how you can use a plugin , it;s not necessary the solution to your problem. The above examples assumed the view object was already initialized , but you can use a new instance of view if you want, or you can use Zend_Registry to share same view object across your application , depending on your needs.
Other alternatives are :
- return the response object , and append or prepend your information ( if it's the same)
- forward the action to another controller/action
Reply With Quote