Navigation Helper

The Navigation helper is a set of tools to figure out which page you are on.

Note that, if the documentation only covers the Twig Extension way (which covers the most common needs), you can also inject the Leapt\CoreBundle\Navigation\NavigationRegistry service into your service/controller to perform the same.

Active paths

Allows checking if the specified path is the current one.

The Twig Extension provides 4 functions:

Usage

{% do add_active_path(path('app_news_index')) %}

<a
    href="{{ path('app_news_index') }}"
    class="{{ is_active_path(path('app_news_index')) ? 'active' : ''}}"
>
    News list
</a>

Easily build breadcrumbs. 3 functions are provided:

Usage

{% do append_breadcrumbs(path('app_news_index'), 'News list') %}
{% do prepend_breadcrumbs(path('app_default_index'), 'ACME Website') %}

{% for breadcrumb in get_breadcrumbs() %}
    {# Index 0 is the path, index 1 is the label #}
    <a href="{{ breadcrumb[0] }}">{{ breadcrumb[1] }}</a>
{% endfor %}

Sitemaps

Utilities