Zend Navigation’s isActive method

Again another Zend Framework issue. I’ve been trying to work out how to detect if a current page is active when using zend navigation. I have setup an XML document with the navigation structure I am after but was having problems detecting if a higher level node in the structure was the currently active branch.

Example:

Page 1
   Sub Page 1
   Sub Page 2 - Currently active page
   Sub Page 3
Page 2
Page 3

I was wanting to know when looking at the top level pages which one of Page 1, Page 2 or Page 3 was the current branch. I know the isActive() method exists for the current page but what I didn’t realise (and is not advertised on the send manual pages) is that passing the parameter “true” to the method makes is recursive.

By calling isActive(true) on the current node I was able to determine if the current branch I was looking at is the actual branch I require.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">