fabrizti Posted March 18, 2013 Share Posted March 18, 2013 (edited) Bonjour je vous explique je suis en production d'un site et j'affiche mes produits par ligne de 3 produits avec imagette titre et description courte. Mon problème est le suivant j'aimerais qu'à chaque fin de ligne soit insérée dans le code un clear ou autre permettant de forcer le retour à la ligne car comme cela est fait actuellement, selon la hauteur des contenus les produits suivants ne sont pas bien rangé en ligne de 3. A noter que chaque case de produit est en css float:left pour les aligner et je pensais mettre un clear:both a chaque fin de ligne de 3. Voici mon code dans la page product-list.tpl <ul id="product_list" class="clear"> <!-- --> {foreach from=$products item=product name=products} <!-- <li class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix"> --> <li class="productlistgauche"> <div class="productlistgauche1"> <div class="blocimgcompare"> <div class="bloccompare"> {if isset($comparator_max_item) && $comparator_max_item} <input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compareProducts) && in_array($product.id_product, $compareProducts)}checked="checked"{/if} /> <label for="comparator_item_{$product.id_product}">{l s='Select to compare'}</label> {/if} </div> <a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}"> <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} class="blocimg" /> </a> <h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:50:' ...'}</a></h3> <p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:130:' ...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:130:' ...'}</a></p> </div> </div> <div class="productlistgauche2"> {if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="on_sale">{l s='On sale!'}</span> {elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="discount">{l s='Reduced price!'}</span>{/if} {if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))} <div class="content_price"> <a class="button lnk_view" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}" style="display: inline;">{l s='View'}</a> {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span>{/if} </div> {if isset($product.online_only) && $product.online_only}<span class="online_only">{l s='Online only!'}</span>{/if} {/if} {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE} {/if} </div> </li> {/foreach} Je pensais utiliser un if modulo 3 =0 et mettre un clear en css mais je n'arrive pas. Help me please Edited March 19, 2013 by fabrizti (see edit history) Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted March 18, 2013 Share Posted March 18, 2013 Il faut que tu utilise l'attribut iteration de smarty: http://www.smarty.net/docsv2/fr/language.function.foreach.tpl et tu fait ton module dessus. 1 Link to comment Share on other sites More sharing options...
fabrizti Posted March 18, 2013 Author Share Posted March 18, 2013 (edited) Merci beaucoup, J'ai donc utilisé au début de ma boucle : {if $smarty.foreach.products.index % 3 == 0} <div class="clear756"></div> {/if} Et c'est résolu Edited March 18, 2013 by fabrizti (see edit history) Link to comment Share on other sites More sharing options...
fabrizti Posted March 18, 2013 Author Share Posted March 18, 2013 Comment mettre que le sujet est résolu ? Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted March 19, 2013 Share Posted March 19, 2013 Il faut éditer le premier message et passer en "use full editor" Link to comment 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