ZF-11012: Zend_View_Helper_Navigation

Description

hi,

Not quite sure about this, as I am implementing it for the first time... But, it appears strange to me that the view_helper_namespace is a constant... This more or less prohibits extending Zend_View_Helper_Navigation to fit my needs with a extension on Zend_View_Helper_Navigation_Menu.

Indeed, by making it a protected var, I could just set another view_helper namespace and create my App_View_Helper_Navigation_Menu without any further issues.

I figure there is a reason for it to be a constant though... And I am curious to know it ? Or I am missing something... And then it would be nice to know what.

The objective would be to be able to display the siblings of the active menu element's parent... Something like this :

Administration '|- Settings '|- Users .....'|- Groups .....'|- Users......[active] '|- Accounts

Right now, when Administration > Users > Users is active, Settings and Accounts are not visible... Which is not very userfriendly.

I know this is not the place to post questions about how ZF works... But I believe this explains why I want to extend Zend_View_Helper_Navigation and Zend_View_Helper_Navigation_Menu.

Cheers ! dGo

Comments

hi,

I have written an extended version of Zend_View_Helper_Navigation_Menu and Zend_View_Helper_Navigation which solves my problem... It now displays the siblings of the parent menu items like this:


menuItem
menuItem
  |-submenuItem
  |-submenuItem
  |-submenuItem
  | |-subsubmenuItem
  | |-subsubmenuItem
  | | |-subsubsubmenuItem
  | | |-subsubsubmenuItem
  | | |-subsubsubmenuItem   
  | |-subsubmenuItem
  |-submenuItem
  |-submenuItem
menuItem
menuItem
menuItem

While trying to fit the code to my needs, I also noticed that Zend_View_Helper_Navigation_Menu did not take the hidden menuItems into account... By slightly modifying {{findActive()}}, I "corrected" this.

I am not quite sure whether I can submit this as a patch or "suggestion" and how I should do this (it seems impossible to attach a ZIP containing my scripts to the issue).

Let me know if this is of any interest to you... dGo

Please have a look on the following issues: {quote} Not quite sure about this, as I am implementing it for the first time... But, it appears strange to me that the view_helper_namespace is a constant... This more or less prohibits extending Zend_View_Helper_Navigation to fit my needs with a extension on Zend_View_Helper_Navigation_Menu.

Indeed, by making it a protected var, I could just set another view_helper namespace and create my App_View_Helper_Navigation_Menu without any further issues. {quote} ZF-10458 - Ability to register custom navigation helpers outside of Zend Library to interact with proxy found in navigation {quote} The objective would be to be able to display the siblings of the active menu element's parent... {quote} ZF-8317 - Zend_View_Helper_Navigation_Menu renderSiblings()

{quote}ZF-8317 - Zend_View_Helper_Navigation_Menu renderSiblings(){quote} Yes, I know about this, but this only renders the siblings of the direct parent of the menuitem... not the ones above.

{quote}ZF-10458 - Ability to register custom navigation helpers outside of Zend Library to interact with proxy found in navigation{quote} ok... I'll implement that... but why hasn't this been added to the framework ?

{quote} Yes, I know about this, but this only renders the siblings of the direct parent of the menuitem... not the ones above. {quote} Can you publish your code at Pastebin or Gist? {quote} ok... I'll implement that... but why hasn't this been added to the framework ? {quote} I can not answer because I am not the author. But at least we have a suggestion for improvement.

{quote}I can not answer because I am not the author. But at least we have a suggestion for improvement.{quote} Obviously... and thanks a lot for that... It did simplify my code a lot !

Here is the code: [http://pastebin.com/37cEpwzw]

In {{findActive()}}, the only thing I really changed is that I removed the {{|| !$this->accept($page)}} statement (line 293) This way it will find the hidden pages as well... (this might have consequences on other libraries, but I have not found any yet)

In {{_renderMenuWithParentSiblings()}} the part that deals with all the parent siblings are located between lines 153 and 177 In first instance, I go through the {{$iterator}} a first time to build a {{$siblings}} array with the pages that have {{$foundPage}} as a child element, and their siblings. All the items that are found in this array have to be displayed (lines 174 through 177) IF the depth is ok and IF they are accepted

As for the usage... Just pass {{renderParentSiblings}}, {{onlyActiveBranch}} and {{renderParents}} as {{true}} in the {{$options}} array when calling {{renderMenu()}} within a view script.

Curious to know if this is a correct way to deal with this problem... Thanks, dGo

{quote} In findActive(), the only thing I really changed is that I removed the || !$this->accept($page) statement (line 293) {quote} This is for access control! [http://framework.zend.com/manual/en/…] {quote} In _renderMenuWithParentSiblings() the part that deals with all the parent siblings are located between lines 153 and 177 {quote} I will have a look at the problem. But at the moment your solution includes too many copied code.

{quote}But at the moment your solution includes too many copied code.{quote} I agree... But if I wanted to reduce this, I would have to refactor {{_renderMenu()}} and cut it into two parts seperating the iterator which accepts the page, or not, from the rest of the code.

{quote}This is for access control!{quote} I know, but I don't think visibility has anything to do with access control.

{quote} I know, but I don't think visibility has anything to do with access control. {quote} No access == no output!

If you have any more questions, please use the mailing list! The issue tracker is not a discussion platform.

Greetings Kaiuwe

{quote}No access == no output!{quote} I agree, but that does not mean the opposite is always true {{no ouput ?= no access}}

{quote}If you have any more questions, please use the mailing list! The issue tracker is not a discussion platform.{quote} I know... But I'll try to refactor the whole some time next week and wanted to make sure I got everything right.

Thanks, dGo

Refactored it is... [http://pastebin.com/BAxhkiaW]

{{findActive()}} is now able to deal with invisible pages if needed when {{$lookForInvisible == true}}. ACL rules are now respected meaning only invisible pages that are allowed by ACL will be found.

Exit {{renderMenuWithParentSiblings()}}. I refactored {{_renderMenu()}} so that it can render the parent's siblings if {{$renderParentSiblings == true}} Default behavior remains the same.

Thus, {{renderMenu()}} remains more or less the same, be it for the extra param that has to get passed through.

I hope this is a little better... Thanks for the advice !