Streize Posted June 2, 2016 Share Posted June 2, 2016 (edited) Bonjour tout le monde d'habitude j'essaie de trouver par moi même, mais là je sèche dessus depuis un moment En gros ce que j'aimerai faire: Si le produit a une photo renseignée, afficher cette photo.Sinon prendre la photo par défaut de la catégorie dans laquelle il se trouve et non plus une photo unique par défaut. Pour le moment j'ai bien réussi à faire cette manip sur le product.tpl Voilà ce que ça donne pour le moment: <div class="product-image-container"> <a class="product_img_link" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url"> <img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" /> {if $category->id == 12} <img itemprop="image" img class="replace-2x img-responsive" src="{$link->getImageLink($product->link_rewrite, $cover.id_image, '12')|escape:'html':'UTF-8'}" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" alt="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}"/> {elseif $category->id == 13} <img itemprop="image" img class="replace-2x img-responsive" src="{$link->getImageLink($product->link_rewrite, $cover.id_image, '13')|escape:'html':'UTF-8'}" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" alt="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}"/> {else} <img itemprop="image" img class="replace-2x img-responsive" src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')|escape:'html':'UTF-8'}" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" alt="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}"/> {/if} </a> Je me suis laissé pour le moment le bout de code par défaut qui appelle la photo du produit et l'image générique par défaut, puis la partie qui fait appelle à la photo selon la catégorie du produit. Un petit lien pour voir ce que ça donne: http://vinsrares.n-dev.fr/presta2/index.php?id_category=12&controller=category En vous remerciant pour votre aide Edited June 2, 2016 by Streize (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted June 3, 2016 Share Posted June 3, 2016 getImageLink(link_rewrite, id_image, format) retourne l'image associé à une produit getCatImageLink(link_rewrite, id_category, format) retourne l'image associé à une catégorie Link to comment Share on other sites More sharing options...
Streize Posted June 3, 2016 Author Share Posted June 3, 2016 (edited) Salut et merci doekia, En gros je cherche la façon d'écrire mes conditions et c'est là que je suis largué. Ca donnerait un truc du genre. Si le produit a une image propre, l'afficher. (vendeur ayant attribué une photo au produit) en utilisant getImageLink(link_rewrite, id_image, format) Sinon afficher l'image correspondant à sa catégorie, donc en utilisant getCatImageLink(link_rewrite, id_category, format) Merci d'avance Edited June 3, 2016 by Streize (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted June 3, 2016 Share Posted June 3, 2016 Ben it te faut récupérer la catégorie (par défaut) depuis le produit $product->id_category_default 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