Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Basic breadcrump for twig
{% if breadcrumb is defined %}
<ol class="breadcrumb">
<li><a href="{{ path('home_page_route') }}"><i class="fa fa-dashboard"></i>Home Page</a></li>
{% for route, name in breadcrumb %}
{% set params = {} %}
{% if name is iterable %}
{% set params = name.params %}
{% set name = name.name %}
{% endif %}
{% if loop.first %}
<li>
<i class="divider"></i>
<a href="{{ path(route,params) }}">{{ name }}</a>
</li>
{% elseif loop.last %}
<li>
<i class="divider"></i>
<a href="{{ path(route,params) }}">{{ name }}</a>
</li>
{% else %}
<li>
<i class="divider"></i>
<a href="{{ path(route,params) }}">{{ name }}</a>
</li>
{% endif %}
{% endfor %}
</ol>
{% endif %}

{% set breadcrumb = { '_route_user_roles_index': 'News', '_route_user_roles_edit' : {'name' : 'Top News','params': {'id': role.id } } } %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment