Code: Select all
{% extends '@nucleus/partials/particle.html.twig' %}
{% macro breadcrumb(seperator="»", home="Home") %}
{% set path = [parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH|split('/')] %}
{# build our "base URL #}
{% set base = _SERVER['HTTPS'] ? 'https' : 'http' ~ '://' ~ _SERVER['HTTP_HOST'] ~ '/' %}
{% set breadcrumbs = ["<a href="~base~">"~home~"</a>"] %}
{#Find out the index for the last value in path array #}
{% set last = path|last %}
{# Build the rest of the breadcrumbs #}
{% for x,crumb in path %}
{# "title" will be displayed (strip out .php and turn '_' into a space #}
{% set title = ucwords(str_replace([('.php', '_'), [('', ' '), crumb]] ) %}
{% if (x != last) %}
{# If we are not on the last index, then display an <a> tag #}
{% set breadcrumbs = "<a href="~base~crumb~">"~title~"</a>" %}
{% else %}
{# Otherwise, just display the title #}
{% set breadcrumbs = title %}
{% endif %}
{% endfor %}
{% set final = [separator,breadcrumbs]|join %}
{% endmacro %}
{% import _self as result %}
Code: Select all
{% block particle %}
<div class="breadcrumb_particle{{ particle.css.class }}" role="navigation">
{{ result.breadcrumb(final) }}
</div>
{% endblock %}