K
K
Karen Mnatsakanyan2017-11-21 19:01:40
Twig
Karen Mnatsakanyan, 2017-11-21 19:01:40

Breadcrumbs on twig?

Greetings !
There is such breadcrumbs in php

<ul class="breadcrumb">
  <?php foreach ($breadcrumbs as $i=> $breadcrumb) { ?>
    <?php if($i+1<count($breadcrumbs)) { ?>
      <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
      &nbsp;&raquo; &nbsp;</li>
    <?php } else { ?>
      <li><?php echo $breadcrumb['text']; ?></li>
    <?php } ?>
  <?php } ?>
</ul>

it needs to be translated into twig somehow
{% for breadcrumb in breadcrumbs %}
  <a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a> »
{% endfor %}

Anyone help me?
thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Karen Mnatsakanyan, 2017-11-21
@karjan

Decision

{% for breadcrumb in breadcrumbs %}
                      		{% if loop.last %}
                      			<span>{{ breadcrumb.text }}</span>
                      		{% else %}
                      			<a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a> » 
                      		{% endif %}
                {% endfor %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question