ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Breadcrumbs, breadcrumbs... Many possibilities, but I want one based on segment_urls ;-)

January 07, 2011 5:37pm

Subscribe [2]
  • #1 / Jan 07, 2011 5:37pm

    Ludvik Herrera

    31 posts

    Hello everyone:

    I have been working in a breadcrumb solution. Yes I have seen plugins and extensions, but I’d like an approach that does not rely on page_uri or categories.

    I want it based on segment_urls.

    I think I am pretty close to this with the code below. It works great and I can add it anywhere.

    <ul class="toasted breadcrumbs">
    <li><a href="http://{site_url}">Home<span class="breadiv"> //</span></a></li>
    {if segment_1}
    <li{if last_segment == segment_1} class="on"{/if}><a href="http://{site_url}/{exp:channel:entries" title=" dynamic=">{title}{/exp:channel:entries}{if segment_2}<span class="breadiv"> //</span>{/if}</a></li>
    {/if}
    {if segment_2}
    <li{if last_segment == segment_2} class="on"{/if}><a href="http://{site_url}/{segment_1}/{exp:channel:entries" title=" dynamic=">{title}{/exp:channel:entries}{if segment_3}<span class="breadiv"> //</span>{/if}</a></li>
    {/if}
    {if segment_3}
    <li{if last_segment == segment_3} class="on"{/if}><a href="http://{site_url}/{segment_1}/{segment_2}/{exp:channel:entries" title=" dynamic=">{title}{/exp:channel:entries}{if segment_4}<span class="breadiv"> //</span>{/if}</a></li>
    {/if}
    {if segment_4}
    <li{if last_segment == segment_4} class="on"{/if}><a href="http://{site_url}/{segment_1}/{segment_2}/{segment_3}/{exp:channel:entries" title=" dynamic=">{title}{/exp:channel:entries}{if segment_5}<span class="breadiv"> //</span>{/if}</a></li>
    {/if}
    </ul>

    But the more I see it, it looks to me that it could be optimized. Right now it accounts for up to four segments. it includes a divider of the segments and it also has a class that let you know you’re on the last_segment.

    Any help or ideas with optimizing these breadcrumbs would be fantastic.

    Ludvik

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases