shazamic Posted April 21, 2014 Share Posted April 21, 2014 (edited) Salut à tous!je pense être pret du but, mais je ne vois pas encore la lumière... Ca fait une bonne semaine que je tourne en rond. Voila mon problème :Je suis en 1.5.6.2.Je veux avoir deux apparences differentes pour afficher mes listes de produits. Pour cela, je pensais dire à Prestashop : pour toutes les category id, tu affiches ce qui suit et pour le category id 23 (uniquement), tu affiches ça. J'ai du coup copié le code de Category-list.tpl àla suite avec l'ajout de la ligne {if $category->id == 23}Avec la modif ci-dessous, ca marche presque : le souci, c'est que pour la cat23, ca m'affiche deux fois la liste, une fois avec l'apparence générale, puis avec l'apparence modifiée. Il faudrait juste que la première liste disparaisse...Mon category-list.tpl modifié (ou charcuté, c'est selon) {* * * @author PrestaShop SA <[email protected]> * @copyright 2007-2012 PrestaShop SA * @version Release: $Revision: 7457 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA *} {if isset($products)} <!-- Products list --> <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"> <div class="left_block"> {if isset($comparator_max_item) && $comparator_max_item} <p class="compare"> <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> </p> {/if} </div> <div class="center_block"> <a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"> <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} /> {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if} </a> <h3><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3> <p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}</a></p> </div> <div class="right_block"> {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"> {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><br />{/if} {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/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 ($product.allow_oosp || $product.quantity > 0)} {l s='Quantity :'} <input id="quantity_wanted_{$product.id_product|intval}" type="text" name="ajax_qty_to_add_to_cart[{$product.id_product|intval}]" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}1{/if}" size="2" maxlength="3" /> {if isset($static_token)} <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}&token={$static_token}", true)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a> {else} <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}", true)} title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a> {/if} {else} <span class="exclusive"><span></span>{l s='Add to cart'}</span><br /> {/if} {/if} <a class="button lnk_view" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a> </div> </li> {/foreach} </ul> <!-- /Products list --> {/if} <!-- Pour liste de la catégorie 23 - panier --> {if $category->id == 23} {if isset($products)} <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"> <div class="left_block"> {if isset($comparator_max_item) && $comparator_max_item} <p class="compare"> <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> </p> {/if} </div> <div class="center_block"> <a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"> <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($mediumSize)} width="{$mediumSize.width}" height="{$mediumSize.height}"{/if} /> {if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if} </a> <h4><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h4> <a class="button lnk_view_panier" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a> </div> <div class="right_block_panier"> {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_panier"> {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><br />{/if} {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/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 ($product.allow_oosp || $product.quantity > 0)} {l s='Quantité :'} <input id="quantity_wanted_{$product.id_product|intval}" type="text" name="ajax_qty_to_add_to_cart[{$product.id_product|intval}]" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}1{/if}" size="2" maxlength="3" /> {if isset($static_token)} <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}&token={$static_token}", true)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a> {else} <a class="button ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}", true)} title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a> {/if} {else} <span class="exclusive"><span></span>{l s='Add to cart'}</span><br /> {/if} {/if} </div> </li> {/foreach} </ul> {/if} {/if} Comme vous pouvez le voir, c'est très bidouille systeme D, je découvre. J'ai compris qu'il faudra que je mette le tout en overide par la suite. Ca sera l'étape n°1568 Merci pour vos conseils ! Edited April 21, 2014 by shazamic (see edit history) Link to comment Share on other sites More sharing options...
shazamic Posted April 21, 2014 Author Share Posted April 21, 2014 Message édité, je m'étais embrouillé (déjà!) entre le category.tpl et le category-list.tpl Link to comment Share on other sites More sharing options...
loulou66 Posted April 21, 2014 Share Posted April 21, 2014 Coucou il vaudrais mieux faire comme suit {if isset($products)} {if category->id == 23} template pour la category 23 {else} template pour les autres category {/if} {/if} @++ Loulou66 Link to comment Share on other sites More sharing options...
shazamic Posted April 21, 2014 Author Share Posted April 21, 2014 Merci Loulou, je viens de tester mais ca coince! Pour simplifier le code, avec ton exemple, j'ai ça : {if isset($products)} {if category->id == 23} allo la terre ? {else} allo la lune ? <!-- /Products list --> {/if} {/if} Ca donne une page blanche. Avec le debug, j'ai ces obscures lignes : ( ! ) Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:\boulot\wamp\www\loKa65\themes\lokaterre\product-list.tpl" on line 30 "{if category->id == 23}" - Unexpected "->"' in C:\boulot\wamp\www\loKa65\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667 ( ! ) SmartyCompilerException: Syntax Error in template "C:\boulot\wamp\www\loKa65\themes\lokaterre\product-list.tpl" on line 30 "{if category->id == 23}" - Unexpected "->" in C:\boulot\wamp\www\loKa65\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667 Faut aller encore plus profond ? Link to comment Share on other sites More sharing options...
loulou66 Posted April 21, 2014 Share Posted April 21, 2014 coucou c'est ma faute ^^ j'ai oublier le $ {if $category->id == 23} donc il reconnait pas la var @++ Loulou66 Link to comment Share on other sites More sharing options...
shazamic Posted April 21, 2014 Author Share Posted April 21, 2014 Oh purée, ça marche ! Je suis joie ! Merci merci Loulou, tu es Grand ! Link to comment Share on other sites More sharing options...
loulou66 Posted April 21, 2014 Share Posted April 21, 2014 Coucou Moi aussi je suis joie tu peut marquer le sujet en resolu ^^ (en modifiant le titre du 1er post) @++ loulou66 Link to comment Share on other sites More sharing options...
shazamic Posted April 21, 2014 Author Share Posted April 21, 2014 already done Link to comment Share on other sites More sharing options...
icstra Posted April 21, 2014 Share Posted April 21, 2014 Vous faites une boutique pour la NASA?..... Link to comment Share on other sites More sharing options...
shazamic Posted April 21, 2014 Author Share Posted April 21, 2014 Non, des produits bio. Mais j'étais tellement loin dans mes recherches de ID, category, else et if que j'errais dans le cosmos depuis une semaine 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