Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
[Solved] Combinate the foreach of this array with a break?

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
ColdDistance
Smarty n00b


Joined: 02 Aug 2013
Posts: 2

PostPosted: Fri Aug 02, 2013 4:10 pm    Post subject: [Solved] Combinate the foreach of this array with a break? Reply with quote

Hi, I want to show a list with the manufacturers of ecomerce, but I have a little problem trying to break the loop.

The loop breaks correctly, but it shows the result of the autoincrement in every iteration. I want to know a way to hide the result of iterations.

Code:
{if $manufacturers}
   <ul>
       {$i=0}
       
      {foreach from=$manufacturers item='manufacturer' name=manufacturer}
            {if $i==5}
                {break}
            {/if}
                 <li>
                    <a href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}" title="{$manufacturer.name|truncate:25:'...'|escape:'htmlall':'UTF-8'}">{$manufacturer.name}</a>
      </li>
               
            {$i++}
      {/foreach}
    </ul>
 

{/if}


Current result.
Back to top
View user's profile Send private message
ColdDistance
Smarty n00b


Joined: 02 Aug 2013
Posts: 2

PostPosted: Fri Aug 02, 2013 4:30 pm    Post subject: Reply with quote

Well, I solved the problem with a span tag and id selector.

I put the span in display:none.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7286
Location: Lincoln Nebraska, USA

PostPosted: Fri Aug 02, 2013 5:24 pm    Post subject: Reply with quote

FYI you don't need to create your own iterator, you can use

$manufacturer@index

inside the loop
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP