Posts: 26
Threads: 2
Joined: Oct 2012
This topic is about the GetSimple Hierarchical Menus plugin, a simple plugin allowing you to display hierarchical page menus.
Installation
Download the latest version here, unzip the downloaded files and copy its contents to your plugins folder.
There are various template functions you can use.
Code: <?php get_hierarchical_navigation(get_page_slug(false)); ?>
displays a hierarchical menu of pages and can be used as a direct replacement for the get_navigation() function.
Code: <?php get_top_navigation(get_page_slug(false)); ?>
displays the top level menus with no child menus.
Code: <?php get_child_navigation(get_page_slug(false)); ?>
displays the child menus of the given page. Useful in sidebar.
Code: <?php get_breadcrumb_navigation(get_page_slug(false), '', true); ?>
displays a breadcrumb navigation bar (exactly like in default theme).
First parameter is current page slug.
Second is seperator between links. (default: bullet).
Third is boolean to include a "home" link. (default: true).
All functions can have a final parameter set to false that will return the menu html rather than display it.
Posts: 2,928
Threads: 195
Joined: Feb 2011
hi,
didn't you re-invent the wheel? There is already a plugin for this, i18N
what is different in your plugin?
Posts: 3,491
Threads: 106
Joined: Mar 2010
The more options to choose from, the better.
I haven't tried this plugin, but I suppose the difference is that you keep the default GS page manager.
Posts: 26
Threads: 2
Joined: Oct 2012
(2012-11-03, 17:58:54)Connie Wrote: hi,
didn't you re-invent the wheel? There is already a plugin for this, i18N
what is different in your plugin?
I totally missed this I had looked through the plugins list but skipped over i18N since I thought it was only multi-language support.
I'm new to GS and i've been writing bits of code for my own use and releasing it if I believe it's useful and doesn't exist.
As you say this IS a re-invention
I'll leave it up but would recommend people to use i18n.
Posts: 2,094
Threads: 54
Joined: Jan 2011
(2012-11-03, 22:26:57)mrdragonraaar Wrote: I'm new to GS and i've been writing bits of code for my own use and releasing it if I believe it's useful and doesn't exist.
As you say this IS a re-invention
It' always good to have a choice, and many people don't need multi-language capabilities and thus can use this simpler plugin instead.
Posts: 26
Threads: 2
Joined: Oct 2012
(2012-11-03, 23:23:28)mvlcek Wrote: (2012-11-03, 22:26:57)mrdragonraaar Wrote: I'm new to GS and i've been writing bits of code for my own use and releasing it if I believe it's useful and doesn't exist.
As you say this IS a re-invention
It' always good to have a choice, and many people don't need multi-language capabilities and thus can use this simpler plugin instead.
Thanks for this.
Although if I had realised the menu support in i18n I wouldn't have needed to write it
The only difference is that I haven't found a way to change the seperator in breadcrumbs yet.
Posts: 2,928
Threads: 195
Joined: Feb 2011
(2012-11-03, 22:26:57)mrdragonraaar Wrote: I'll leave it up but would recommend people to use i18n.
no, that's not necessary ;=)
GetSimple = keep it simple ;=)
and your plugin is a simple one-purpose-plugin and that is good and helpful!
If you have other plugins (new inventions or "rewrites" ) let us know!
Cheers and thank you for your contribution,
Connie
Posts: 26
Threads: 2
Joined: Oct 2012
(2012-11-04, 00:08:10)Connie Wrote: (2012-11-03, 22:26:57)mrdragonraaar Wrote: I'll leave it up but would recommend people to use i18n.
no, that's not necessary ;=)
GetSimple = keep it simple ;=)
and your plugin is a simple one-purpose-plugin and that is good and helpful!
If you have other plugins (new inventions or "rewrites" ) let us know!
Cheers and thank you for your contribution,
Connie
Thanks Connie
Posts: 15
Threads: 5
Joined: Oct 2012
Thanks mrdragonraaar
I've decided to use your plugin for my breadcrumbs and it works very nicely! :-)
Posts: 16
Threads: 0
Joined: Mar 2010
Thanks for your work! Nice plugin!
There is a suggestion for internationalization: add HMENU_HOME key into lang file for "Home" text and change line 159 in functions.php to
Code: $menu_html = '<a class="home" href="' . get_site_url(false) . '" title="'. i18n_r('hierarchical_menus/HMENU_HOME') .'">'. i18n_r('hierarchical_menus/HMENU_HOME') .'</a>' . $seperator . $menu_html;
Posts: 26
Threads: 2
Joined: Oct 2012
Thanks folks.
xStranger - I have added your suggestion. Not quite sure why I hadn't already added it. Weird.
Posts: 1,928
Threads: 88
Joined: Apr 2010
Is there a way to keep children's menu pages on all child pages?
Posts: 12
Threads: 2
Joined: Aug 2011
2013-01-29, 23:43:08
(This post was last modified: 2013-01-29, 23:47:18 by miagrimm.)
(2012-11-19, 17:45:22)Oleg06 Wrote: Is there a way to keep children's menu pages on all child pages?
that is a good question, I am stuck on this, too... Has this been resolved/answered ?
I have main menu and submenu in php and css, but need to figure out how to show "sister" menu of child pages when displaying submenu pages... Thnx
cheers, M.
Posts: 2
Threads: 0
Joined: Mar 2013
(2013-01-29, 23:43:08)miagrimm Wrote: (2012-11-19, 17:45:22)Oleg06 Wrote: Is there a way to keep children's menu pages on all child pages?
that is a good question, I am stuck on this, too... Has this been resolved/answered ?
I have main menu and submenu in php and css, but need to figure out how to show "sister" menu of child pages when displaying submenu pages... Thnx
cheers, M.
This may help.
I find the parent of the current page and show its siblings if they are not top menu items. I only use 2 level menu.
PHP Code: function nav_side_data($parentslug) { $menu_data = menu_data(); $child_menu_data = array();
foreach ($menu_data as $menu) { if ($menu['slug'] == $parentslug) { $grandparentslug = $menu['parent_slug']; } }
foreach ($menu_data as $menu) { if ($menu['parent_slug'] == $parentslug || ($menu['parent_slug'] == $grandparentslug && $menu['parent_slug'] != '')) { $child_menu_data[] = $menu; } }
return($child_menu_data); }
Posts: 4
Threads: 0
Joined: Apr 2013
mrdragonraaar
(or anyone else)
I design my websites using the twitter bootstrap methodology, but it seems i cannot implement this in this plugin...
Twitter uses this style... Is there anyway to use this as well???
Code: <ul class="nav nav-pills">
<li class="dropdown">
<a class="dropdown-toggle"
data-toggle="dropdown"
href="#">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<!-- links -->
</ul>
</li>
</ul>
http://twitter.github.com/bootstrap/comp....html#navs
Posts: 6,266
Threads: 181
Joined: Sep 2011
I use a i18n nav component for my bootstrap menus.
Posts: 4
Threads: 0
Joined: Apr 2013
(2013-04-05, 07:46:53)shawn_a Wrote: I use a i18n nav component for my bootstrap menus.
and does this work out of the box??? or is there at least templating available??
Posts: 6,266
Threads: 181
Joined: Sep 2011
I18nnav ccomponent templating , see the plugins docs.
Posts: 4
Threads: 0
Joined: Apr 2013
(2013-04-05, 09:17:10)shawn_a Wrote: I18nnav ccomponent templating , see the plugins docs.
I have tried and failed getting a working dropdown going, yet I feel i am pretty close.
Could you share your component?
Posts: 6,266
Threads: 181
Joined: Sep 2011
PHP Code: $ismenu = false; $caret = $dropdown = $dropdown_list = '';
$classStr = $item->classes; $classes = explode(' ',$item->classes); if(in_array('current',$classes)) $classStr .= ' active'; if(in_array('currentpath',$classes)) $classStr .= ' active';
if($item->hasChildren and ($item->isOpen or $ismenu==true)){ if(in_array('open',$classes)) $classStr .= ' dropdown'; $dropdown = 'data-toggle="dropdown" class="dropdown-toggle"'; $dropdown_list = ' class="dropdown-menu"'; $caret = '<b class="caret"></b>'; $classStr = str_replace('open','',$classStr); }
?> <li class="<?php echo $classStr; ?>"> <a href="<?php echo htmlspecialchars($item->link) . "\""; echo ' '.$dropdown; ?> > <?php # debugLog(htmlspecialchars($item->text)); echo htmlspecialchars($item->text); echo $caret ?> </a> <?php if ($item->isOpen) { ?> <ul<?php echo $dropdown_list.'>'; $item->outputChildren(); ?></ul> <?php } ?> </li>
I added an active classs to 3.2 so that piece may no longer be needed.
Hope it gets you started somewhere.
Posts: 4
Threads: 0
Joined: Apr 2013
(2013-04-08, 00:15:27)shawn_a Wrote: PHP Code: $ismenu = false; $caret = $dropdown = $dropdown_list = '';
$classStr = $item->classes; $classes = explode(' ',$item->classes); if(in_array('current',$classes)) $classStr .= ' active'; if(in_array('currentpath',$classes)) $classStr .= ' active';
if($item->hasChildren and ($item->isOpen or $ismenu==true)){ if(in_array('open',$classes)) $classStr .= ' dropdown'; $dropdown = 'data-toggle="dropdown" class="dropdown-toggle"'; $dropdown_list = ' class="dropdown-menu"'; $caret = '<b class="caret"></b>'; $classStr = str_replace('open','',$classStr); }
?> <li class="<?php echo $classStr; ?>"> <a href="<?php echo htmlspecialchars($item->link) . "\""; echo ' '.$dropdown; ?> > <?php # debugLog(htmlspecialchars($item->text)); echo htmlspecialchars($item->text); echo $caret ?> </a> <?php if ($item->isOpen) { ?> <ul<?php echo $dropdown_list.'>'; $item->outputChildren(); ?></ul> <?php } ?> </li>
I added an active classs to 3.2 so that piece may no longer be needed.
Hope it gets you started somewhere.
oh wow!! this works PERFECTLY!! thank you so much£.
Posts: 46
Threads: 9
Joined: Jan 2013
Connie, there are a number of i18N plugins. Which one has dropdown menus?
Thanks.
Don
(2012-11-03, 17:58:54)Connie Wrote: hi,
didn't you re-invent the wheel? There is already a plugin for this, i18N
what is different in your plugin?
Posts: 218
Threads: 59
Joined: May 2013
2013-09-30, 06:45:13
(This post was last modified: 2013-09-30, 06:45:30 by phpman.)
Shawn,
what i must do to use this code you wrote to get a dropdown menue
in the theme "http://get-simple.info/extend/theme/office-memo/576/"
if i add I18N it dosn´t work the same if i use Hierarchical Menus plugin
Hope anyone can help me !
Thanks in advance.
best regards,
Harald
Posts: 1
Threads: 0
Joined: Sep 2016
I was using this and wanted to be able to mark the current page, the parent page and the grandparent page as current, so that My top menu would have the grandparent menu item highlighted, no matter which of those pages people were on. Here is the code to do this if anybody else wants to:
I modified the function menu_html as follows:
I added this code to the top of the function in order to determine the grandparent.:
$menu_data = menu_data();
$parentslug = get_parent(false);
foreach ($menu_data as $menu)
{
if ($menu['slug'] == $parentslug)
{
$grandparentslug = $menu['parent_slug'];
}
}
Then I modified the following code to have them all marked as current:
from this:
if ($currentpage == $menu['slug'])
{
$classes = 'current ' . $classes;
}
to this:
if ((get_parent(false) == $menu['slug']) || ($grandparentslug == $menu['slug']) || ($currentpage == $menu['slug']))
{
$classes = 'current ' . $classes;
}
Thanks to the publisher of Hierarchical menus! It was nice to have so much coding already done for me.
Posts: 23
Threads: 9
Joined: Jan 2020
It's an old post/plugin; I want to use it but it doesn't work, it displays exactly the same menu as standard i.e. on one line without sub- ... maybe I have missed something
can someone helps ?
tkx,
Domi.
|