Smarty reverse order of a foreach

I am evaluating whether or not to use cs-cart ecommerce software and it uses something foreign to me: smarty templating!

I wanted to reverse the order of the breadcrumb path used as the page title text:

{strip}<title>
{foreach from=$breadcrumbs item=i name="bkt"}
	{if $smarty.foreach.bkt.index==1} {/if} - {if !$smarty.foreach.bkt.first}{$i.title|escape}{if !$smarty.foreach.bkt.last} - {/if}{/if}
{/foreach} {$lang.page_title_text}</title>{/strip}

How can i set this up so that the breadcrumb used is reversed (as i want the product ame to be first not last for the page title)? Also, i seem to be getting extra '-'s where i shouldn’t.

Can anyone help?

Foreach cannot go in reverse order.

Either you reverse the array in you PHP file using array_reverse or you do it in your template file with the [url=http://smarty.php.net/manual/en/language.function.section.php]{section} tag (reverse example in doc page).

Mmm…thanks for the reply. It looks like all the php files are encoded :frowning: and i tried replacing the foreach with section and it broke the site. I think i’m in over my head here. It’s a shame as cs-cart looks great particularly backend, but it’s useless if i can hack it for my needs :frowning:

Can you show us the code you have used in your template file and broke the whole site?

Maybe you can contact the guys at cs-cart and ask them to fix it for you…