domdas Posted January 24, 2012 Share Posted January 24, 2012 Bonjour, Je sollicte votre aide car je n'arrive pas à classer les accessoires d'un produit dans leur catégorie respective sans faire des doublons. Voici le code modifié de la page product.tpl avec 2 boucles foreach imbriquées : {if isset($accessories) AND $accessories} <!-- accessories --> <ul id="idTab4" > <div class="accessories_block clearfix"> <div class="block_content"> {foreach from=$accessories key='category' item='group'} <h3>{$group.category_default}</h3> <ul> {foreach from=$accessories item='accessory' name='accessories_list'} {assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)} {if $group.category == $accessory.category} <li> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{$accessory.legend|escape:'htmlall':'UTF-8'}" class="product_image"><img src="{$link->getImageLink($accessory.link_rewrite, $accessory.id_image, 'medium')}" alt="{$accessory.legend|escape:'htmlall':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a> <div id="product_prix"> {if $accessory.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<span class="price">{if $priceDisplay != 1}{displayWtPrice p=$accessory.price}{else}{displayWtPrice p=$accessory.price_tax_exc}{/if}</span>{/if} {if ($accessory.allow_oosp || $accessory.quantity > 0) AND $accessory.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <a class="exclusive button ajax_add_to_cart_button" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$accessory.id_product|intval}&token={$static_token}&add" rel="ajax_id_product_{$accessory.id_product|intval}" title="{l s='Add to cart'}">{l s='Add to cart'}</a> {else} <span class="exclusive">{l s='Add to cart'}</span> <span class="availability">{if (isset($accessory.quantity_all_versions) && $accessory.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span> {/if} </div> <div id="product_desc"> <h5><a href="{$accessoryLink|escape:'htmlall':'UTF-8'}">{$accessory.name|escape:'htmlall':'UTF-8'}</a></h5> <p> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='More info'}">{$accessory.description_short|strip_tags|truncate:300:'...'}</a> <a href="{$accessoryLink|escape:'htmlall':'UTF-8'}">[{l s='More info'}]</a> </p> </div> </li> {/if} {/foreach} </ul> {/foreach} </div> </div> </ul> {/if} Les boucles posent problème mais je ne trouve pas la faille ! D'avance merci. Link to comment Share on other sites More sharing options...
domdas Posted January 25, 2012 Author Share Posted January 25, 2012 Petite précision... en fait, j'ai juste besoin de connaître le code smarty pour éliminer les doublons de ma première boucle : {foreach from=$accessories key='category' item='group'} Avec cette boucle je récupère bien toutes les catégories de mes accessoires produit mais je ne sais pas comment faire pour éliminer les doublons. Quelqu'un aurait-il une piste ? 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