Smarty templating get second last element

Viewed 17

Our designer wants to show only the parent of the last item in the breadcrumb. So if you are in My account > Addresses > Add new address, the breadcrumb should only show:

< Addresses

I'm not particularly known with Smarty, can this be done in some way?

This is the breadcrumb code I am working with at the moment:

<nav data-depth="{$breadcrumb.count}" class="breadcrumb">
<ul class="list-group list-group-flush list-group-horizontal m-0 p-0 d-flex">
    {block name='breadcrumb'}
        {foreach from=$breadcrumb.links item=path name=breadcrumb}
            {block name='breadcrumb_item'}
                  <li class="list-group-item border-0">
                    <img src="{$urls.img_url}/icons/icon-back-account-arrow.svg" class="icon-svg"  alt=""/>
                    <a href="{$path.url}" class="ms-2">
                        {$path.title}
                    </a>
                  </li>
            {/block}
        {/foreach}
    {/block}
</ul>
</nav>

I am thinking of assigning a var to the last item and only showing that but I'm not sure how to go about it. Maybe something like:

{assign var=toShow value=($breadcrumb.count - 1)}

But I'm not sure how to use that in the loop.. Can someone help me in the right direction?

0 Answers
Related