[fw-general] How can I extend Zend_View_Helper_Navigation_Menu?

2011-03-16 Thread Peter Sharp
I'm trying to find a way to extend the menu view helper in order to make a
few changes to the way it handles ACL, but I cant seem to find a way to make
it use mine instead of the zend version.

I have the file located at Custom/View/Helper/Navigation/Menu.php under
library (class name 'Custom_View_Helper_Navigation_Menu')

I feel like I have tried every variation under the sun, but I cant seem to
get anything to make this work.

// from bootstrap

$this-bootstrap('layout');
$layout = $this-getResource('layout');
$view = $layout-getView();

$view-addHelperPath('Custom/View/Helper', 'Custom_View_Helper');

   
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')-setView($view);

Is there something I'm missing or am I just going about it all wrong?

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/How-can-I-extend-Zend-View-Helper-Navigation-Menu-tp3383587p3383587.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] How can I extend Zend_View_Helper_Navigation_Menu?

2011-03-16 Thread Hector Virgen
Zend's Navigation_* view helpers are not located in the same place as all of
the other Zend view helpers. This means the parent Navigation view helper
has to register a new prefix/path pair on its own.

Normally this prefix/path pair gets registered *after* your application is
bootstrapped. This means your prefix paths end up looking like this:

Zend_View_Helper = Zend/View/Helper
Custom_View_Helper = Custom/View/Helper
Zend_View_Helper_Navigation = Zend/View/Helper/Navigation

Since Zend_View uses a LIFO stack for resolving view helper paths, it ends
up finding the menu helper in the path Zend/View/Helper/Navigation and
uses that one -- which is not what you want.

To get around this, you can manually register the prefix/path for Zend's
navigation helpers and then register your custom path. I normally use
application.ini for this:

   resources.view.helperPath.Zend_View_Helper_Navigation =
Zend/View/Helper/Navigation
resources.view.helperPath.Custom_View_Helper = Custom/View/Helper

This results in a prefix/path stack that looks like this:

Zend_View_Helper = Zend/View/Helper
Zend_View_Helper_Navigation = Zend/View/Helper/Navigation
Custom_View_Helper = Custom/View/Helper

At this point Zend_View should now be able to find your custom menu view
helper.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com