spawns Posted April 6, 2010 Posted April 6, 2010 Slt à tous,j'essai de modifier un petit module pour me faire la main avec smarty et autres mais étant novice je bute sur un petit blem.j'aurai besoin de sortir d'une boucle "foreach" au 3eme élément sur une boucle en contenant 4 {foreach from=$xml->link item=home_link name=links}{literal} { src: '{/literal}{$this_path}{$home_link->img}{literal}', {/literal}{if $home_link->url}{literal}href: '{/literal}{$home_link->url}{literal}' }{/literal}{/if}{literal},{/literal}{/foreach} car il ne faut pas que mon 4eme élément finissent par la virgule de fin de boucleen code html il faut que ca donne ca en gros { src: '../modules/essai/link0.jpg', href: 'product.php?id_product=35' }, { src: '../modules/essai/link1.jpg', href: 'product.php?id_product=12' }, { src: '../modules/essai/link2.jpg', href: 'product.php?id_product=10' }, { src: '../modules/essai/link3.jpg', href: 'product.php?id_product=25' } j'espère avoir été assez claire.Merci d'avance de votre aide@+Sujet déplacé au bon endroit -yoya971 Share this post Link to post Share on other sites More sharing options...
Yoya Posted April 7, 2010 Posted April 7, 2010 A tester .... {php}break;{/php} A bientot,Pierre. Share this post Link to post Share on other sites More sharing options...
spawns Posted April 7, 2010 Posted April 7, 2010 ok mais comment le faire a partir du 3eme élément Share this post Link to post Share on other sites More sharing options...
Yoya Posted April 7, 2010 Posted April 7, 2010 {assign var="i" value=$i|default:0} {foreach from=$products item=product name=products} {assign var="i" value=$i+1} ... mon code {if $i gte 3} {php}break;{/php} {/if} {/foreach} Cdlt,Pierre. Share this post Link to post Share on other sites More sharing options...
spawns Posted April 7, 2010 Posted April 7, 2010 Merci yoya971c'est exactement ce que je cherché a faire, j'ai encore du boulot pour maitriser tous ca.Encore merci@+ Share this post Link to post Share on other sites More sharing options...
terresdesiem Posted August 19, 2011 Posted August 19, 2011 j'ai eu besoin de faire la même chose, merci pour cette aide !! Share this post Link to post Share on other sites More sharing options...
sirokoweb Posted July 23, 2012 Posted July 23, 2012 Bonjour, J'ai acheté le module vente privées prestashop; j'essaye de faire quelques petites modifications... mais en vain! Tout d'abord, le module propose sur la home un foreach avec la liste de toutes les ventes privées, comment bloquer le foreach à 3 ventes par exemple? le code ressemble à ça: <ul> {foreach from=$img_list item=img} {if $img != '.' && $img != '..'} <li><a href="{$pvs_link}"><img width="730px" height="160px" src="{$img}" alt="{l s='Private Sale' mod='privatesale'}" /></a></li> {/if} {/foreach} </ul> J'ai fait quelques tests avec {php}break;{/php} mais je casse littéralement le site... <ul> {assign var="i" value=$i|default:0} {foreach from=$img_list item=img} {assign var="i" value=$i+1} {if $img != '.' && $img != '..'} <li><a href="{$pvs_link}"><img width="730px" height="160px" src="{$img}" alt="{l s='Private Sale' mod='privatesale'}" /></a></li> {/if} {if $i gte 3} {php}break;{/php} {/if} {/foreach} </ul> Une idée pour m'aider à sortir de ce foreach? Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now