am-impact / amnav
Navigation Plugin for Craft
Installs: 26 505
Dependents: 0
Suggesters: 0
Security: 0
Stars: 168
Watchers: 17
Forks: 19
Open Issues: 21
Type:craft-plugin
Requires
- composer/installers: ~1.0
README
Navigations in Craft, made easy
Functionality
In the plugin's settings you can adjust the plugin's name for your customers and disable adding, editing and deleting navigations for non-admins.
The navigations overview. If you disabled the Can add, edit and delete setting in the plugin's settings, non-admins will only see the created navigations and the link to start building their navigation.
When you create or edit a navigation, you can set the following settings:
Let's start building a navigation! Non-admins don't see the Display navigation section. This is for admins only so they know what to put in the templates. You have the option to add existing entries, categories, assets or..
.. add your own URLs.
When you have saved your nodes in the navigation, you can edit them later by double clicking on the node, or use the setting button behind the node when you hover over a node.
Variables
You have two ways to fetch your navigation. You can get an array with your added nodes, or let a&m nav create the HTML for you.
{% set nav = craft.amNav.getNavRaw("yourNavigationHandle") %}
or
{{ craft.amNav.getNav("yourNavigationHandle") }}
Build the way you like it
Now you can add your own HTML if necessary!
{% set nav = craft.amNav.getNavRaw("yourNavigationHandle") %}
{% macro addNodeToNavigation(node, index) %}
{%- set nodeClasses = [] -%}
{%- if node.hasChildren -%}
{%- set nodeClasses = nodeClasses|merge(['has-children']) -%}
{%- endif -%}
{%- if node.active or node.hasActiveChild -%}
{%- set nodeClasses = nodeClasses|merge(['active']) -%}
{%- endif -%}
{%- if node.level == 1 and index == 1 -%}
{%- set nodeClasses = nodeClasses|merge(['first']) -%}
{%- endif -%}
{%- if node.listClass|length -%}
{%- set nodeClasses = nodeClasses|merge([node.listClass]) -%}
{%- endif -%}
<li{% if nodeClasses|length %} class="{{ nodeClasses|join(' ') }}"{% endif %}>
<a href="{{ node.url }}" title="{{ node.name }}"{% if node.blank %} target="_blank"{% endif %}>{{ node.name }}</a>
{% if node.hasChildren %}
<ul class="nav__level{{ (node.level + 1) }}">
{% for subnode in node.children %}
{{ _self.addNodeToNavigation(subnode, loop.index) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
<nav class="navmain">
<ul class="nav">
{% for node in nav %}
{{ _self.addNodeToNavigation(node, loop.index) }}
{% endfor %}
</ul>
</nav>
Parameters
Let amnav do the trick
{{ craft.amNav.getNav("yourNavigationHandle") }}
or with parameters..
{{ craft.amNav.getNav("yourNavigationHandle", {
id: 'navigation',
class: 'navigation'
}) }}
Parameters
Breadcrumbs
Breadcrumbs are not based on a created navigation. They are based on the current URL segments.
{{ craft.amNav.getBreadcrumbs() }}
or with parameters..
{{ craft.amNav.getBreadcrumbs({
id: 'breadcrumbs',
class: 'breadcrumbs'
}) }}
Parameters
Contact
If you have any questions, suggestions or noticed any bugs, don't hesitate to contact us.