0

Issue

I really need to extend Zend_View_Helper_Navigation_Menu for my custom behaviour of its methods. I use modules if it's important for you to know.

Some solutions

My problem

I've implemented all the solutions, their combinations and it still ends in failure... Guys, I am waiting for ANY hints.

Edit: The problem is that nothing happens. The standard helper is used (which works fine).

My code

My Bootstrap.php file:

protected function _initNavigation() {
    $this->bootstrap('view');
    $view = $this->getResource('view');

    $view->addHelperPath('/../library/Application/View/Helper/Navigation', 'Application_View_Helper_');     
    $view->navigation($this->doGetNavigation());
}

My Application_View_Helper_Navigation_Menu class (ROOT/library/Application/View/Helper/Navigation):

class Application_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    public function menu(Zend_Navigation_Container $container = null)
    {
        echo 'Application_View_Helper_Navigation_Menu::menu(...)';
        return parent::menu($container);
    }
}

My Zend_Debug::dump($this->getHelperPaths()) calling on view:

array (size=3)
    'Zend_View_Helper_' =>
array (size=1)
    0 => string 'Zend/View/Helper/' (length=17)
    'Application_View_Helper_' =>
array (size=1)
    0 => string '/../library/Application/View/Helper/Navigation/' (length=47)
    'Fleet_View_Helper_' =>
array (size=1)
    0 => string 'C:/repos/statistics/trunk/application/modules/fleet/views\helpers/' (length=70)

My script view:

echo $this->navigation()->menu();
Community
  • 1
  • 1
dbq
  • 111
  • 2
  • 11

1 Answers1

0

Have in application.ini

resources.view.helperPath.Test_View_Helper_ = APPLICATION_PATH "/views/helpers"
resources.view.helperPath.Test_View_Helper_Navigation = APPLICATION_PATH "/views/helpers/Navigation"

then in application/views/helpers/Navigation.php

class Test_View_Helper_Navigation extends Zend_View_Helper_Navigation
{
    public function navigation(Zend_Navigation_Container $container = null)
    {
         $this->view->getHelper ('Menu');
         $this->_helper ['menu'] = new Test_View_Helper_Navigation_Menu();
     return parent::navigation($container);
    }
}

in application/views/helpers/Navigation/Menu.php

class Test_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    public function render(Zend_Navigation_Container $container = null)
    {
        return 'It is I.';
    }
}
akond
  • 15,865
  • 4
  • 35
  • 55