Download the PHP package gibbs/phile-sub-navigation without Composer
On this page you can find all versions of the php package gibbs/phile-sub-navigation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gibbs/phile-sub-navigation
More information about gibbs/phile-sub-navigation
Files in gibbs/phile-sub-navigation
Package phile-sub-navigation
Short Description Generates a philecms nested hierarchy
License MIT
Homepage http://dangibbs.co.uk/
Informations about the package phile-sub-navigation
PhileCMS Sub Navigation
A PhileCMS plugin that generates a hierarchy tree that can be used to make nested navigation menus.
1. Installation
Install via composer
Install via git
Clone this repository from the directory into . E.g:
Manual Install
Download and extract the contents into:
2. Plugin Activation
Activate the plugin in your file:
3. Parameters
This plugin returns a variable named . Each item in the site hierarchy has the following parameters:
-
- True when the item is the current page
-
- How deep the current page is nested.
-
- The associated pages meta information
-
- The current path e.g.
-
- The pages parent
-
- An alias of
-
- The full URL to the page
4. Example Usage
To be flexible NO HTML is generated by this plugin - that is the responsibility of the template engine you are using.
More examples are available on the wiki
Children of a particular path, for example can be used by referencing the children key.
Twig - List /blog/ children
<ul>
{% for item in navigation.blog.children %}
<li>
<a href="{{ item.uri }}">{{ item.meta.title }}</a>
</li>
{% endfor %}
</ul>
Twig - List /blog/archive/ children
<ul>
{% for item in navigation.blog.children.archive.children %}
{% if item.active %}
<li class="active">
{% else %}
<li>
{% endif %}
<a href="{{ item.uri }}">{{ item.meta.title }}</a>
</li>
{% endfor %}
</ul>
Twig - Entire site hierarchy example
<!-- Twig Macro -->
{% macro sub_navigation(navigation) %}
{% import _self as macros %}
{% for item in navigation %}
<li>
<a href="{{ item.uri }}">{{ item.meta.title }}</a>
{% if item.children %}
<ul>
{{ macros.sub_navigation(item.children) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% import _self as macros %}
<ul>{{ macros.sub_navigation(navigation) }}</ul>
To debug the plugin output set inside the plugins file.
4. Caching
Caching is disabled by default and depends on (enabled by default).
To enable caching edit the plugins file and set cache to true.
NOTE: Caching will cause some parameters such as to stop working.