Manu-41 Posted November 6, 2022 Share Posted November 6, 2022 (edited) Bonjour, j'ai installé un module qui affiche les marques sur la home page. Je voudrais afficher uniquement les ID que j'ai besoin (3 pour commencer), et non les 30 marques. Voici le code que j'ai dans le module : {foreach from=$manufacturers item=manufacturer name=manufacturer_list} {if $manufacturer.image} <li class="{if $smarty.foreach.manufacturer_list.last}last_item{elseif $smarty.foreach.manufacturer_list.first}first_item{else}item{/if}"> <div class="pb-3"><span>{$manufacturer.id_manufacturer}</span> <div> <a href="{Context::getContext()->link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'html'}"> <img class="radius-50" src="{$urls.base_url}img/m/{$manufacturer.image_url}" alt="{$manufacturer.name|escape:'html':'UTF-8'} "/> </a> </div> <div class="description mt-3 pt-3"> <p class="mb-0">{$manufacturer.short_description|strip_tags:'UTF-8'|truncate:180:'...' nofilter}</p> </div> </div> </li> {/if} {/foreach} j'ai essayé d'ajouter ma condition, mais ca ne fonctionne pas. {if isset($manufacturers) && ($manufacturer.id_manufacturer == 11 || && $category.id == 32 || && $category.id == 15)} Ai-je une erreur dans ma condition ? Merci pour votre aide. Ps 1.7 Edited November 7, 2022 by Manu-41 reesolu (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted November 6, 2022 Share Posted November 6, 2022 C’est OU ou c’est ET donc soit || ou soit && et et isset manufacturers ne sert à rien puisque on est dans la boucle foreach Link to comment Share on other sites More sharing options...
Manu-41 Posted November 6, 2022 Author Share Posted November 6, 2022 Merci pour ta réponse, j'ai repris une condition d'affichage que j'avais sur les catégories. Du coup, je voudrais juste afficher quelques marques selon leur id. Est ce bon ? Link to comment Share on other sites More sharing options...
Manu-41 Posted November 6, 2022 Author Share Posted November 6, 2022 {$manufacturer.id_manufacturer== 11 && $category.id == 32 && $category.id == 15)} Link to comment Share on other sites More sharing options...
Mediacom87 Posted November 6, 2022 Share Posted November 6, 2022 {foreach from=$manufacturers item=manufacturer name=manufacturer_list} {if $manufacturer.image && ($manufacturer.id_manufacturer == 11 || $manufacturer.id_manufacturer == 32 || $manufacturer.id_manufacturer == 15)} <li class="{if $smarty.foreach.manufacturer_list.last}last_item{elseif $smarty.foreach.manufacturer_list.first}first_item{else}item{/if}"> <div class="pb-3"><span>{$manufacturer.id_manufacturer}</span> <div> <a href="{Context::getContext()->link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'html'}"> <img class="radius-50" src="{$urls.base_url}img/m/{$manufacturer.image_url}" alt="{$manufacturer.name|escape:'html':'UTF-8'} "/> </a> </div> <div class="description mt-3 pt-3"> <p class="mb-0">{$manufacturer.short_description|strip_tags:'UTF-8'|truncate:180:'...' nofilter}</p> </div> </div> </li> {/if} {/foreach} 1 Link to comment Share on other sites More sharing options...
Manu-41 Posted November 7, 2022 Author Share Posted November 7, 2022 8 hours ago, Mediacom87 said: {foreach from=$manufacturers item=manufacturer name=manufacturer_list} {if $manufacturer.image && ($manufacturer.id_manufacturer == 11 || $manufacturer.id_manufacturer == 32 || $manufacturer.id_manufacturer == 15)} <li class="{if $smarty.foreach.manufacturer_list.last}last_item{elseif $smarty.foreach.manufacturer_list.first}first_item{else}item{/if}"> <div class="pb-3"><span>{$manufacturer.id_manufacturer}</span> <div> <a href="{Context::getContext()->link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'html'}"> <img class="radius-50" src="{$urls.base_url}img/m/{$manufacturer.image_url}" alt="{$manufacturer.name|escape:'html':'UTF-8'} "/> </a> </div> <div class="description mt-3 pt-3"> <p class="mb-0">{$manufacturer.short_description|strip_tags:'UTF-8'|truncate:180:'...' nofilter}</p> </div> </div> </li> {/if} {/foreach} Mille Merci Mediacom!!!!! ça fonctionne bien. Ça m'a bien aidé ! 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