Zend Framework Widget Tutorial Task

I am trying to follow this guide, but I cannot get it to work:

http://weierophinney.net/matthew/archives/246-Using-Action-Helpers-To-Implement-Re-Usable-Widgets.html

I did everything as described, but I do not know how to make it available in my controllers. My file system looks like this:

- application - controllers - IndexController.php - modules - user - configs user.ini - controllers - forms Login.php - helpers HandleLogin.php - views - scripts login.phmtl profile.phtml Bootstrap.php - views 

How to use HandleLogin Helper in my IndexController? I really have no idea, and I look at trying for more than a day, and I almost want to throw my computer out of the window;). Therefore any help would be appreciated!

+2
source share
2 answers

It seems that the widget plugin is not called anywhere.

A few things to check:

  • Do you have a Bootstrap.php file for the module?
  • Does this bootstrap file have a _initWidgets() method?
  • This method is called:

    $widget = new Module_Widget_Name; // is it callable?
    Zend_Controller_Action_HelperBroker::addHelper($widget);

  • Have you registered a widget resource?

    public function _initResourceLoader()
    {
    $loader = $this->getResourceLoader();
    $loader->addResourceType('helper', 'helpers', 'Helper');
    $loader->addResourceType('widget', 'widgets', 'Widget');

     return $loader; 

    }

  • Is there an application.ini string resources.modules[] = ?

+2
source

You do not do. The goal of the tutorial is to create a reusable widget that works independently of any specific controllers. When the application receives the request, it will start the submit loop and automatically start the action assistant in preDispatch:

Now let's look at the action assistant. We remind you that action helpers can define hooks for init () (called by the auxiliary broker each time it is passed to the new controller), preDispatch () (called before the controller hooks preDispatch () and the action itself), and postDispatch () (executed after the action and postDispatch () of the controller).

The helper will get the current controller (depending on what might be for this request) to get an instance of View and configure it using the form

0
source

All Articles