Hi, I am experiencing a problem with marking navigation pages as active in a
ZF2 application (beta 3).

I have a navigation container with MVC pages 'on multiple routes', so I have
to explicitly specify the 'route' option for every page. The hrefs are
constructed fine, but marking pages as active works wrong.

If there are more pages reachable by the same route, all such pages are
marked as active in the rendered menu. E.g. a 'Zend\Mvc\Router\Http\Segment'
route defined as '/mycontroller[:/action]' routes to pages
'/mycontroller/bar' as well as '/mycontroller/foo'. If both these pages are
defined in the navigation container and you navigate to any one of them,
both are marked as active in the menu.

I think the problem is in the Zend\Navigation\Page\Mvc::isActive() method,
where the page is marked as active as soon as the name of the route defined
for the page matches the name of the current actual route (line 125). No
other conditions are examined and the isActive() method returns true. Is
this a bug or am I doing something fundamentally wrong?

As a side note and a separate problem: The isActive() method relies on the
routeMatch object present in the MVC page. Is there any facility built into
the ZF2 or the Skeleton App which helps with injecting the routeMatch object
into every MVC page in a container? I haven't found any info/docs on this,
so I wrote my own simple injector class and call it from the render listener
defined in the Module class. Am I missing something here?

Thanks for any help.

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Marking-pages-as-Active-in-Zend-Navigation-tp4623784.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to