|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ColdDistance Smarty n00b
Joined: 02 Aug 2013 Posts: 2
|
Posted: Fri Aug 02, 2013 4:10 pm Post subject: [Solved] Combinate the foreach of this array with a break? |
|
|
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 |
|
ColdDistance Smarty n00b
Joined: 02 Aug 2013 Posts: 2
|
Posted: Fri Aug 02, 2013 4:30 pm Post subject: |
|
|
Well, I solved the problem with a span tag and id selector.
I put the span in display:none. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Aug 02, 2013 5:24 pm Post subject: |
|
|
FYI you don't need to create your own iterator, you can use
$manufacturer@index
inside the loop |
|
Back to top |
|
|
|
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
|