ZF-8023: Zend_Navigation_Page_Mvc getHref() should have option to set escape to false
Description
I noticed that the getHref() method of Zend_Navigation_Page_Mvc uses the default URL helper to generate the link to a page. However, the first three parameters are passed to it (params array, route string, resetparams boolean), but the fourth (escape boolean) isn't. As I have a recursive page structure in which my regex route accepts a path param with for example the string '/page1/page2/page3/pageN', the default getHref() and thus the breadcrumbs escape these slashes which generates a wrong link.
I solved this by overruling the getHref() method in my own Page class, but I think it's strange that this parameter can't be passed to the default URL helper, unlike the other three.
Comments
Posted by Patrick Barnes (patrickbarnes) on 2010-03-22T18:03:02.000+0000
I have also run into this issue - The router routes hand-typed urls properly, (A regex router sending for example: /pages/path1/path2/pagename to ('module'=>'pages','controller'=>'index','action'=>'index',1=>'path1/path2/pagename') - The url helper does not generate the same url in reverse - path1/path2/pagename is urlencoded, and I don't want it to be.
I would suggest that deciding whether to urlencode parameters should be able to be done by the route configuration. Something like routes.myroute.urlencoding = false or something?
Posted by Ulrich Beckers (ubeckers) on 2010-03-31T05:44:33.000+0000
I also ran into this issue. I fixxed it in my setup by patching the class "Zend_Navigation_Page_Mvc". (see attached file) I changed following lines:
89-95 209-212 403-417 438-441 474
Posted by Ulrich Beckers (ubeckers) on 2010-03-31T05:49:02.000+0000
Oh, I forgot: After this patch, I was able to configure the navigation pages like this:
... array( 'label' => 'Link 123', 'route' => 'content', 'module' => 'default' , 'controller' => 'content', 'action' => 'content', 'encodeUrl' => false, ) ...
Posted by Stewart Lord (stewartlord) on 2010-04-26T15:27:04.000+0000
I also ran into this issue. Ulrich's patch would match my expectations - although, I might name the option 'encode' or 'encodeParams' instead of 'encodeUrl'.
Another work-around, is to generate the url outside of Zend_Navigation using url helpers and set the uri explicitly.