Structured Menu is a GetSimple-plugin, that translates the flat menustructure of the GetSimple-standard-menu into a structured one. The plugin is an hybrid, to speed up its performance in the render-phase.
The download and the use of Structured Menu is free and unlimited! You can get it here: http://www.hofrichter.net/getsimple/structured-menu.zip
The part, that implements the hookin-action is designed to speed up the component-output while the render-phase. It reads the menu-structure to build up the final structured menu. The plugin-logic translates the one-dimensional array into a n-dimensional array (n = maximum menu-depth). The configuration is saved as a json-object.
The function-part is the logic, that you (the template-designer/-developer) use to inject the menu into your page. You can choose between two kinds of data-output and three kinds of filtering.
get_structured_menu(...)This function returns a wellformed HTML-structure. There are three options.
The default-implementation (with no function-attributes) can be done like this (place this in your template):
<?php get_structured_menu(); ?>
The ouput will be like the following example. The values of the
class-attribute are always like shown in the example and contains
enough informations to build up a clear css-design. The options of the links
<a ...>...</a> will contain the individual settings
of your menu.
<ul class="menu-level-0">
<li class="menu-item-0"><a href="?id=page1" title="Page-title 1">Page-title 1</a>
<ul class="menu-level-1">
<li class="menu-item-0"><a href="?id=page1-1" title="Page-title 1.1">Page-title 1.1</a></li>
<li class="menu-item-1"><a href="?id=page1-2" title="Page-title 1.2">Page-title 1.2</a></li>
<li class="menu-item-2"><a href="?id=page1-3" title="Page-title 1.3">Page-title 1.3</a></li>
</ul>
</li>
<li class="menu-item-1"><a href="?id=page2" title="Page-title 2">Page-title 2</a>
<ul class="menu-level-1">
<li class="menu-item-0"><a href="?id=page2.1" title="Page-title 2.1">Page-title 2.1</a>
<ul class="menu-level-2">
<li class="menu-item-0"><a href="?id=page2-2-1" title="Page-title 2.2.1">Page-title 2.2.1</a></li>
<li class="menu-item-1"><a href="?id=page2-2-2" title="Page-title 2.2.2">Page-title 2.2.2</a></li>
<li class="menu-item-2"><a href="?id=page2-2-3" title="Page-title 2.2.3">Page-title 2.2.3</a></li>
</ul>
</li>
<li class="menu-item-1"><a href="?id=page2-2" title="Page-title 2.2">Page-title 2.2</a></li>
</ul>
</li>
<li class="menu-item-1"><a href="?id=page3" title="Page-title 3">Page-title 3</a></li>
</ul>It is possible to display this part of the menu, that matches the given slug (first parameter of the function). Attention: Structured Menu works on the built-in menu definition only. You can not filter for pages, that are not part of the menu.
<?php get_structured_menu('page2.1'); ?>
The ouput will be like the following example.
<ul class="menu-level-0">
<li class="menu-item-0"><a href="?id=page2.1" title="Page-title 2.1">Page-title 2.1</a>
<ul class="menu-level-1">
<li class="menu-item-0"><a href="?id=page2-2-1" title="Page-title 2.2.1">Page-title 2.2.1</a></li>
<li class="menu-item-1"><a href="?id=page2-2-2" title="Page-title 2.2.2">Page-title 2.2.2</a></li>
<li class="menu-item-2"><a href="?id=page2-2-3" title="Page-title 2.2.3">Page-title 2.2.3</a></li>
</ul>
</li>
</ul>The same filter as shown in "option 2", but incl. the path to the root-menu-item.
<?php get_structured_menu('page2.1', true); ?>
The ouput will be like the following example.
<ul class="menu-level-0">
<li class="menu-item-0"><a href="?id=page2" title="Page-title 2">Page-title 2</a>
<ul class="menu-level-1">
<li class="menu-item-0"><a href="?id=page2.1" title="Page-title 2.1">Page-title 2.1</a>
<ul class="menu-level-2">
<li class="menu-item-0"><a href="?id=page2-2-1" title="Page-title 2.2.1">Page-title 2.2.1</a></li>
<li class="menu-item-1"><a href="?id=page2-2-2" title="Page-title 2.2.2">Page-title 2.2.2</a></li>
<li class="menu-item-2"><a href="?id=page2-2-3" title="Page-title 2.2.3">Page-title 2.2.3</a></li>
</ul>
</li>
</ul>
</li>
</ul>get_structured_menu_array(...)The default-implementation (with no function-attributes) can be done like this (place this in your template):
<?php get_structured_menu_array(); ?>
The result will be a structured php array as you can see in the example below.
Array
(
[page1] => Array
(
[slug] => page1
[url] => http://localhost/getsimple/
[parent_slug] =>
[title] => Page-title 1
[menu_priority] => 1
[menu_text] => Page-title 1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:32:48 +0200
[children] => Array
(
[page1-1] => Array
(
[slug] => page1-1
[url] => http://localhost/getsimple/
[parent_slug] => page1
[title] => Page-title 1.1
[menu_priority] => 5
[menu_text] => Page-title 1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page1-2] => Array
(
[slug] => page1-2
[url] => http://localhost/getsimple/
[parent_slug] => page1
[title] => Page-title 1.2
[menu_priority] => 7
[menu_text] => Page-title 1.2
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:56 +0200
)
[page1-3] => Array
(
[slug] => page1-3
[url] => http://localhost/getsimple/
[parent_slug] => page1
[title] => Page-title 1.3
[menu_priority] => 7
[menu_text] => Page-title 1.3
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:35:33 +0200
)
)
)
[page2] => Array
(
[slug] => page2
[url] => http://localhost/getsimple/
[parent_slug] =>
[title] => Page-title 2
[menu_priority] => 1
[menu_text] => Page-title 2
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:32:48 +0200
[children] => Array
(
[page2-1] => Array
(
[slug] => page2-1
[url] => http://localhost/getsimple/
[parent_slug] => page2
[title] => Page-title 2.1
[menu_priority] => 5
[menu_text] => Page-title 2.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
[children] => Array
(
[page2-1-1] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-2] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-3] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
)
)
[page2-2] => Array
(
[slug] => page2-2
[url] => http://localhost/getsimple/
[parent_slug] => page2
[title] => Page-title 2.2
[menu_priority] => 7
[menu_text] => Page-title 2.2
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:56 +0200
)
)
)
[page3] => Array
(
[slug] => page3
[url] => http://localhost/getsimple/
[parent_slug] =>
[title] => Page-title 3
[menu_priority] => 1
[menu_text] => Page-title 3
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:32:48 +0200
)
)It is possible to display this part of the menu, that matches the given slug (first parameter of the function). Attention: Structured Menu works on built-in menu definition only. You can not filter for pages, that are not part of the menu.
<?php get_structured_menu_array('page2-1'); ?>
The ouput will be like the following example.
Array
(
[page2-1] => Array
(
[slug] => page2-1
[url] => http://localhost/getsimple/
[parent_slug] => page2
[title] => Page-title 2.1
[menu_priority] => 5
[menu_text] => Page-title 2.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
[children] => Array
(
[page2-1-1] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-2] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-3] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
)
)
)The same filter as shown in "option 2", but incl. the path to the root-menu-item.
<?php get_structured_menu_array('page2-1', true); ?>
The ouput will be like the following example.
Array
(
[page2] => Array
(
[slug] => page2
[url] => http://localhost/getsimple/
[parent_slug] =>
[title] => Page-title 2
[menu_priority] => 1
[menu_text] => Page-title 2
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:32:48 +0200
[children] => Array
(
[page2-1] => Array
(
[slug] => page2-1
[url] => http://localhost/getsimple/
[parent_slug] => page2
[title] => Page-title 2.1
[menu_priority] => 5
[menu_text] => Page-title 2.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
[children] => Array
(
[page2-1-1] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-2] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
[page2-1-3] => Array
(
[slug] => page2-1-1
[url] => http://localhost/getsimple/
[parent_slug] => page2-1
[title] => Page-title 2.1.1
[menu_priority] => 5
[menu_text] => Page-title 2.1.1
[menu_status] => Y
[private] =>
[pub_date] => Tue, 22 Oct 2013 08:34:07 +0200
)
)
)
)
)
)You can use this plugin for free without any limitation. © 2013 http://www.hofrichter.net