Current Parent - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13) +--- Thread: Current Parent (/showthread.php?tid=5611) |
Current Parent - mank319 - 2014-02-07 Hello everyone! I just wanted to share my latest little contribution to the GetSimple CMS. A plugin, that adds the "current" class to the parent navigation list item of the active page, so the entrys of both the current page and it's parent are highlighted. More information can be found here. RE: Current Parent - Timbow - 2014-02-08 Thanks Manuel. Downloaded, tested and uploaded to a live site. Definitely an improvement in clarity. Appreciated. I like to use the child-menu plugin. It keeps everything small and simple. RE: Current Parent - mank319 - 2014-02-08 Thanks for your feedback. I am glad to hear, that is useful! :-) RE: Current Parent - shawn_a - 2014-02-08 I imagine this is useless without a multi level plugin ? I mean what would it provide for a parent in a a flat 1 d menu ? RE: Current Parent - Carlos - 2014-02-08 I use this in my templates to highlight the current page or parent in the (1-level) menu. PHP Code: <?php get_navigation(get_parent(false)==''?return_page_slug():get_parent(false)); ?> RE: Current Parent - shawn_a - 2014-02-08 fyi new arg for get_nav in 3.3. get_navigation($currentpage,$classPrefix = "") * @param string $classPrefix Prefix that gets added to the parent and slug classnames prevent issues if you have slugs names menu,error,footer who that might conflict with template css classes. or if you want to modify the menu on certain pages or other prefix you want to add for selectors RE: Current Parent - mank319 - 2014-02-08 (2014-02-08, 00:55:59)shawn_a Wrote: I imagine this is useless without a multi level plugin ?Yes, as I explained I use it with Child Menu. May be of use with the Nested Menu plugin aswell, I guess. (2014-02-08, 01:20:07)Carlos Wrote: I use this in my templates to highlight the current page or parent in the (1-level) menu.Thanks for the hint! That's similar to the way I wanted to accomplish it beforehand. But I prefered to incorporate the functionality into a modular plugin, that is independend of the theme used, so it can be reused and easily installed by folks, who do not want to tinker with code at all. @shawn_a: is there any way to call the get_navigation function without echoing? This way one could benefit from the cleaner looking code of Carlos' example, but still retain the advantages of a modular solution, like mine. RE: Current Parent - shawn_a - 2014-02-08 You can build your own menu using your own function, but no. you can use the filter "menuitems" to filter the html before it is returned. or use output_buffering to grab the html from the function return. RE: Current Parent - mank319 - 2014-02-08 (2014-02-08, 02:42:21)shawn_a Wrote: You can build your own menu using your own function, but no.Thanks for the reply! Well building my own menu (like e.g. Nested Menu does) is what I tried to avoid, because that would rely on changing theme code aswell. I prefer to keep the plugin as modular and independent as possible. Glad to hear, that using the "menuitems" filter is the proper procedure to achieve it, because that's what my plugin already does :-) RE: Current Parent - mank319 - 2014-02-08 @Timbow (and pretty much everybody else using Child Menu): By the way, I have tweaked the theme I was using to integrate nicely with Child Menu. http://get-simple.info/extend/theme/blacksimpleextended/765/ RE: Current Parent - Carlos - 2014-02-08 (2014-02-08, 01:50:42)mank319 Wrote: Thanks for the hint! That's similar to the way I wanted to accomplish it beforehand. Yes, yes, of course. It's a nice and handy plugin that makes this easier. (2014-02-08, 02:48:45)mank319 Wrote: Well building my own menu (like e.g. Nested Menu does) is what I tried to avoid, because that would rely on changing theme code aswell. I prefer to keep the plugin as modular and independent as possible. Using menuitems you could: - return an empty string so that get_navigation echoes nothing, and echo your own menu. or - replace the whole string and replace it by your own menu so that get_navigation echoes it instead. RE: Current Parent - shawn_a - 2014-02-08 Or use domloader and manipulate it as nodes, I have done this before but its a pita. You have to add a charset and then remove the html later, cause php requires the string to be proper html PHP Code: $dom_document = new DOMDocument(); RE: Current Parent - xxdex - 2014-02-14 it's working only for a two level menu.. how to integrate it for a multilevel menu.. no only two levels ? active menu in the seccond level is activating a top menu as active (awesome) but when i click and go to the page in the third level of menu.. this will only give me a active the button in the seccond level menu and third menu level.. the top level menu (1) is not active. how to fix it ? RE: Current Parent - mvlcek - 2014-02-14 (2014-02-14, 03:17:22)xxdex Wrote: it's working only for a two level menu.. The I18N plugin marks the navigation item of the current page with class=current and all parents with class=currentpath, see e.g. here. RE: Current Parent - mank319 - 2014-02-16 (2014-02-14, 03:17:22)xxdex Wrote: it's working only for a two level menu.. Hi and sorry for the delay :-) Well for that purpose one would probably have to parse $menudata and generate the whole navigation menu, because I don't know if it is somehow possible to call get_parent for a page other than the active one. Right now I am just altering the generated HTML via the menuitems filter. I have chosen this approach, because I wanted the plugin to work with the default get_navigation function for those people who do not want to tinker with any code and don't feel like replacing something in their template.php file. If you find a solution to implement this without having to write an own get_navigation function I would really appreciate your contribution! Otherwise I guess i18n really is better suited for more complex tasks like this. |