I'm looking to create a navigation breadcrumb on my CMS Made Simple site. I'm looking to use smarty/php but I'm having problems making sure it's future-proof - i.e can handle multiple levels.
Here's the sample tree structure I am looking to get working:
-Root
-About us
--Test
---Level 3
-Services
-Contact Us
Here's my code (minus styling):
{assign var="uri" value=$smarty.server.REQUEST_URI|pathinfo}
{assign var="exploded" value="/"|explode:$uri["dirname"]}
<a href="http://{$smarty.server.HTTP_HOST}">Home</a>
{foreach from=$exploded item=element}
{if $element != ""}
::<a href="http://{$smarty.server.HTTP_HOST}/
{foreach from=$exploded item=element2}
{if $element2 != ""}
{$element2}/
{/if}
{/foreach}
">{$element|replace:'-':' '}</a>
{/if}{*close the if blank if*}
{/foreach}
::{$uri["filename"]|replace:'-':' '}
And here's my current output
<a href="http://www.libraryplustrust.org.uk">Home</a>
:: <a href="http://www.libraryplustrust.org.uk/about-us">about us</a>
:: <a href="http://www.libraryplustrust.org.uk/test">test</a>
:: level3
Problem is that the 2nd layer (test) is not being "added on" to the "about-us" parent file. Any ideas would be warmly received.