Superbegood31 Posted November 8, 2013 Share Posted November 8, 2013 Bonjour, Je cherche à ajouter les images produits au module "latestcomments" Voilà mon bout de code du fichier php du module ... public function hookRightColumn($params) { if($this->_getModuleHook() == 3) { $getConfig = $this->getLastCommentsConfig(); $image = Product::getCover((int)Tools::getValue('id_product')); $nb = $getConfig['nb']; $this->smarty->assign(array( 'misc' => $getConfig, 'latestcomments_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], 'smallSize' => Image::getSize('small'), 'latestcomments' => $this->_createLatestComments($nb, null) )); return $this->display(__FILE__, 'latestcomments.tpl'); } } ... Et le bout de code du template ... {foreach from=$latestcomments item=lastcomment name=lastcomment} <li class="{if $smarty.foreach.lastcomment.first}first_comment{elseif $smarty.foreach.lastcomment.last}last_comment{else}comment{/if}" {if $misc.scroll == 1}style="height: {$misc.row}px;"{/if}> <h5><a href="{$link->getProductLink($lastcomment.id_product, $lastcomment.link_rewrite)}" title="{$lastcomment.name|escape:'htmlall':'UTF-8'}"> <img src="{$link->getImageLink($lastcomment.link_rewrite, $latestcomments_cover, 'small')}" height="{$smallSize.height}" width="{$smallSize.width}" alt="{$lastcomment.name|escape:'htmlall':'UTF-8'}" /> {$lastcomment.name|escape:'htmlall':'UTF-8'}</a></h5> ... Malheureusement aucunes images, il me manque les id des produits et des images avant le small... Voici l'url où l'on voit le /0-small/ http://monsite/0-small/monproduit.jpg Merci pour vos lumières Link to comment Share on other sites More sharing options...
franckm1000 Posted November 9, 2013 Share Posted November 9, 2013 (edited) C'est quoi cette fonction: _createLatestComments($nb, null) Pour savoir où tu en es, traques tes variables avec des echo. Par exemple commences par faire: echo '->'.Tools::getValue('id_product').'<br />->'.$image['id_image']; Fais également un print_r de ton $image pour voir la gueule de ton tableau. Fait également un echo de ton Tools::get('id_product') pour être sûr de bien récupérer l'id produit Edited November 9, 2013 by franckm1000 (see edit history) Link to comment Share on other sites More sharing options...
Superbegood31 Posted November 12, 2013 Author Share Posted November 12, 2013 Bonjour, @franckm1000 : merci pour ton aide, j'ai résolu en partie mon problème en ajoutant à la requête SQL les images produits. Par contre, le small ne se rajoute pas après l'id de l'image Ex : http://maboutique/3-61/monproduit.jpg Voici mes bouts de code php public function hookRightColumn($params) { if($this->_getModuleHook() == 3) { $getConfig = $this->getLastCommentsConfig(); $nb = $getConfig['nb']; $this->smarty->assign(array( 'misc' => $getConfig, 'smallSize' => Image::getSize('small'), 'latestcomments' => $this->_createLatestComments($nb, null) )); return $this->display(__FILE__, 'latestcomments.tpl'); } } tpl <img src="{$link->getImageLink($lastcomment.link_rewrite, $lastcomment.id_product, $lastcomment.id_image, 'small')}" height="{$smallSize.height}" width="{$smallSize.width}" alt="{$lastcomment.name|escape:'htmlall':'UTF-8'}" /> Merci pour votre aide. 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