When I pass a list of items to the menu tag, e.g.:
{menu template='mytemplate' items='home,about,products'}
I lose any child nodes. So, for example, if I have a number of pages that are children of the "products" page, none of them appear in the "products" sub-menu. In fact, there is no "products" sub-menu. If I remove the "items" parameter to {menu}, then the "products" sub-menu appears just fine. But this defeats the purpose, because I was hoping to selectively display top-level menus.
I looked at the menu manager code and, at first glance, it's hard to say whether this is an oversight or intentional. I think it boils down to GetChildNodes() never being called, which is never called because $rootnode is never defined when "items" is set. But I haven't examined the code closely enough to see whether it would even make sense to call GetChildNodes() in this context.
I also tried passing all of the page aliases in the "items" parameter, but this just gives me a huge top-level menu without any of the hierarchy that I've set up -- all the items are on the top-level, no matter what their parent is.
This seems counter-intuitive, which is why I thought it might have been an oversight. Then again, is it just the way that the "items" parameter was intended to be used?
Ultimately, what I'm trying to do here is to show different top-level menu items depending on whether a user is logged in or not (for example, "Sign Up" should not be displayed for a logged-in user, and vice versa, "My Account" should not be displayed for a visitor).
So I wrote a UDT that calls FrontEndUsers->LoggedIn() to see if the user is logged in, and then passes back, as a Smarty variable, a list of top-level page aliases (i.e., those with parent-id -1). The list varies depending on the return value of LoggedIn(). I call this UDT from my template, and then pass the resulting Smarty variable to {menu} as the value of the "items" parameter.
Ideally I would like to see "items" maintain the page hierarchy, but if the behavior of "items" is not subject to change, is there a better way for me to selectively display menu items?
Thanks, Ben
Should passing a list of items to the menu tag override the page hierarchy?
Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Return to “Developers Discussion”
Jump to
- Official Boards
- ↳ README FIRST!!!
- ↳ Announcements
- ↳ General Discussion
- Support Boards
- ↳ CMSMS Core
- ↳ Modules/Add-Ons
- ↳ Help Wanted (commercial)
- ↳ Translations
- Community Boards
- ↳ Tips and Tricks
- ↳ CMS Show Off
- ↳ Layout and Design (CSS & HTML)
- ↳ Feature ideas
- ↳ Developers Discussion
- ↳ The Lounge
- International Discussions
- ↳ Czech/Slovak - Česky/Slovensky
- ↳ Danish - Dansk
- ↳ Dutch - Nederlands
- ↳ Aankondigingen
- ↳ Tips en Trucs
- ↳ Vertalingen & Documentatie
- ↳ Hulp gezocht (commercieel)
- ↳ Finnish - Suomi
- ↳ French - Français
- ↳ German - Deutsch
- ↳ BITTE ZUERST LESEN !!!
- ↳ Ankündigungen
- ↳ Installation und Einstellungen
- ↳ Module und Tags
- ↳ Smarty-Tipps und -Tricks
- ↳ Layout und Design
- ↳ Suchmaschinenoptimierung (SEO)
- ↳ HowTo's
- ↳ Übersetzungen
- ↳ Show Off
- ↳ Hilfe gesucht (kommerziell)
- ↳ Stammtisch
- ↳ Hungarian - Magyar
- ↳ Italian - Italiano
- ↳ Moduli/Plugins
- ↳ Lithuanian - Lietuviškai
- ↳ Darbo / bendradarbiavimo pasiūlymai ir paieška
- ↳ Persian / Farsi
- ↳ Polish - Polski
- ↳ Portuguese - Português
- ↳ Russian - русский
- ↳ Предложения и поиск РАБОТЫ
- ↳ Spanish - Español
- ↳ Swedish - Svenska
- Geekmoot Editions
- ↳ Geekmoot 2016
- ↳ Connections and Conversations
- ↳ Geekmoot 2015
- ↳ Geek Moot 2012
- ↳ Locked: Geek Moot 2010
- Old Forums
- ↳ [locked] CMSMS 2.0 Beta
- ↳ Module Developers
- ↳ Closed Issues
- ↳ [locked] Documentation0ld
- ↳ Suggestions, Modifications & Corrections
- ↳ [locked] CMSMS 1.11 Beta
- ↳ Closed Issues
- ↳ [locked] CMSMS 1.10 Beta
- ↳ Closed Issues
- ↳ [locked] CMSMS 2.2 Beta
- ↳ [locked] CMSMS MLE fork
- ↳ Modules/Addon patchs
- ↳ [locked] Quality Assurance
- ↳ [locked] Accessability and Usability
- ↳ [locked] Documentation
- ↳ Media and presentations about CMSMS
- ↳ [locked] Installation, Setup and Upgrade