Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Presta 1.4 : Afficher des caractéristiques produits

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
Nazo74
Smarty n00b


Joined: 18 Aug 2011
Posts: 4

PostPosted: Fri Aug 26, 2011 9:57 pm    Post subject: Presta 1.4 : Afficher des caractéristiques produits Reply with quote

Bonjour à tous,

Je personnalise de ma boutique prestashop (v 1.4) et j'ai un soucis que je n'arrive malheureusement pas à régler seul. Je sollicite donc votre aide.

Je suis en train de modifier le module produits phare. L'idée est de remplacer la "short description" par 3 caractéristiques produit. Voici le code actuel :

Code:
<ul>
                        {foreach from=$products item=product name=homeFeaturedProducts}
                                <li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}clear{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}">
                                        <h5><a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'}</a></h5>
                                        <div class="product_desc"><a href="{$product.link}" title="{l s='More' mod='homefeatured'}">{$product.description_short|strip_tags|truncate:130:'...'}</a></div>
                                        <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" /></a>
                                        <div>
                                                {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if}
                                                <a class="button" href="{$product.link}" title="{l s='View' mod='homefeatured'}">{l s='View' mod='homefeatured'}</a>
                                                {if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}
                                                        {if ($product.quantity > 0 OR $product.allow_oosp) AND $product.customizable != 2}
                                                        <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart.php')}?qty=1&amp;id_product={$product.id_product}&amp;token={$static_token}&amp;add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>
                                                        {else}
                                                        <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span>
                                                        {/if}
                                                {else}
                                                        <div style="height:23px;"></div>
                                                {/if}
                                        </div>
                                </li>
                        {/foreach}
                        </ul>


J'ai repéré le code à modifier :

Code:
<a href="{$product.link}" title="{l s='More' mod='homefeatured'}">{$product.description_short|strip_tags|truncate:130:'...'}</a>


J'ai fais des recherches. Il semberait que pour afficher les caractéristiques produits, il faut utiliser la variable $features. J'ai vu aussi que certains recommandent de s'inspirer du fichier product.tpl. Notamment :

Code:
{foreach from=$features item=feature}
                        <li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>
                {/foreach}


Mon problème c'est que j'ai beau essayer de combiner dans tous les sens, ca ne fait pas. Un coup ca ne m'affiche aucune caractéristique, un coup ca ne m'affiche plus rien. Bref la galère. Auriez vous une idée?

Je pense que ca ne marche pas parce que ma variable feature n'est pas définie dans le fichier php du module produit phare. Je ne saurai pas la définir car je ne connais pas le language Smarty mais en toute logique, je dois bien pouvoir trouver un module ou elle l'est. Auquel cas j'aurais plus qu'à faire un copier coller dans le fichier php du module produit phare. Qu'en dites vous? La logique me semble bonne.

Quelqu'un a t'il une idée d'un module ou la variable feature est définie? (ca m'éviterait de devoir tous les fouiller). Après, je ne sais pas si c’était une fausse affirmation ou si ce n'est plus vrai pour la version 1.4 mais j'ai lu sur un forum que la variable feature (mais pas seulement) serait définie globalement dans prestashop et que finalement elle serait accessible partout. Ca vous parle? En tout les cas, si c'est vrai, alors je ne comprends pas pourquoi ca ne marche pas...

Merci d'avance pour votre aide.

Cordialement
Back to top
View user's profile Send private message
Nazo74
Smarty n00b


Joined: 18 Aug 2011
Posts: 4

PostPosted: Sun Aug 28, 2011 6:48 pm    Post subject: Reply with quote

personne n'a d'idée?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP