SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    UK
    Posts
    539
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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:

    PHP Code:
    {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?

  2. #2
    SitePoint Member
    Join Date
    Aug 2006
    Location
    Sighisoara/ClujNapoca - Romania
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 {section} tag (reverse example in doc page).

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    UK
    Posts
    539
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmm..thanks for the reply. It looks like all the php files are encoded 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

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Location
    Sighisoara/ClujNapoca - Romania
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •