2010年6月24日星期四

Re: [fw-mvc] Extending navigation view helpers

Thanks Jurian. I like your suggestion, but maybe a simpler solution would be to place the ZF nav helper path closer to the beginning of the stack instead of the end. The final stack would go from looking like this:

Zend_View_Helper => Zend/View/Helper
My_View_Helper => My/View/Helper
Zend_View_Helper_Navigation => Zend/View/Helper/Navigation

to:

Zend_View_Helper_Navigation => Zend/View/Helper/Navigation
Zend_View_Helper => Zend/View/Helper
Default_View_Helper => application/views/helpers

Come to think of it, I suppose a quick fix that wouldn't involve any changes to the ZF source would be to explicitly add the ZF nav helper path to the view *before* adding any custom paths. A quick change to my application.ini should resolve this:

; View
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views"
resources.view.helperPath.Zend_View_Helper_Navigation = "Zend/"
resources.view.helperPath.Default_View_Helper = APPLICATION_PATH "/views/helpers"

Thanks for the help! :)

--
Hector


On Thu, Jun 24, 2010 at 5:50 AM, Jurian Sluiman <subscribe@juriansluiman.nl> wrote:
I had exact the same case precise a year ago ;)
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-visible-
in-sitemap-not-in-menu-td658632.html#a658633


I suggested to use a fallback when the default view helpers are not available,
but I never got an answer to that.

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

On Thursday 24 Jun 2010 01:01:00 Hector Virgen wrote:
> Thanks, Jeroen. I think I'll go with that for now, but it would be nice if
> there was a better way.
>
> --
> Hector
>
> On Wed, Jun 23, 2010 at 3:46 PM, Jeroen Keppens
<jeroen.keppens@gmail.com>wrote:
> > I ended up doing exactly that (you hack), so I'm really curious aswell to
> > see other people's suggestions on this.
> >
> > Jeroen
> >
> > On 24 Jun 2010, at 00:40, Hector Virgen wrote:
> > > Hello,
> > >
> > > I need to extend Zend_View_Helper_Navigation_Menu to modify one of its
> >
> > methods. However, when calling $this->navigation()->menu() from within a
> > view, I always get the ZF version instead of my custom version. This
> > seems to happen because Zend_View_Helper_Navigation implicitly adds
> > Zend/View/Helper/Navigation to the end of the view helper's plugin loader
> > stack. Due to the stack being LIFO, it always returns the ZF helper
> > instead of mine.
> >
> > > Any suggestions on how to get around this? I'm considering giving my
> >
> > extended version a different name (such as "mymenu") but that seems like
> > a bit of a hack.
> >
> > > --
> > > Hector

没有评论: