Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hierarchical Menus
#1
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.
Reply
#2
hi,

didn't you re-invent the wheel? There is already a plugin for this, i18N

what is different in your plugin?
|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#3
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.
Reply
#4
(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 Smile 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 Smile

I'll leave it up but would recommend people to use i18n.
Reply
#5
(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 Smile

It' always good to have a choice, and many people don't need multi-language capabilities and thus can use this simpler plugin instead.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
(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 Smile

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 Smile
The only difference is that I haven't found a way to change the seperator in breadcrumbs yet.
Reply
#7
(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
|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#8
(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 Smile
Reply
#9
Thanks mrdragonraaar

I've decided to use your plugin for my breadcrumbs and it works very nicely! :-)
Reply
#10
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;
Reply
#11
Thanks folks.

xStranger - I have added your suggestion. Not quite sure why I hadn't already added it. Weird.
Reply
#12
Is there a way to keep children's menu pages on all child pages?
Reply
#13
(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.
Reply
#14
(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);

Reply
#15
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
Reply
#16
I use a i18n nav component for my bootstrap menus.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#17
(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??
Reply
#18
I18nnav ccomponent templating , see the plugins docs.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#19
(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?
Reply
#20
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.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#21
(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£.
Reply
#22
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?
Reply
#23
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
Reply
#24
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.
Reply




Users browsing this thread: 1 Guest(s)