am-impact / amnav

Navigation plugin for Craft
168 stars 20 forks source link

target not added in "build your own" menu #10

Closed robbiepost closed 9 years ago

robbiepost commented 9 years ago

Hi,

We've created a "build your own" type of menu according to your example. however when you add a menu item that should open in a new (blank) page, the code is not rendered in the actual "build your own" menu.

{% set nav = craft.amNav.getNavRaw("mainMenu") %}

{% macro addPageToNavigation(page) %}
<li class="{% if page.active %} active{% endif %} {% if page.children is defined %} dropdown{% endif    %}">
    <a href="{{ page.url }}" title="{{ page.name }}" {% if page.children is defined %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}>{{ page.name }} {% if page.children is defined %}<b class="icon-angle-down"></b>{% endif %}</a>

    {% if page.children is defined %}
        <ul class="dropdown-menu">
            {% for subpage in page.children %}
                {{ _self.addPageToNavigation(subpage) }}
            {% endfor %}
        </ul>
    {% endif %}

</li>
{% endmacro %}

<ul class="level0 nav navbar-nav navbar-right">
{% for page in nav %}
    {{ _self.addPageToNavigation(page) }}
{% endfor %}
</ul>

{{ craft.amNav.getNav("mainMenu") }}
hubertprein commented 9 years ago

You're missing the blank variable.

If you would like to know which variables are available, just set devMode to true in your config and dump page variable.

Use the following in your macro and it'll work:

{% if page.blank %} target="_blank{% endif %}