metta Posted January 5, 2010 Share Posted January 5, 2010 Hello everyone,Happy New Year.I would like to add supplier logo images according to different category in the product page above the short description. For example: Category 3 is Nike, Category 4 is Gucci, and Category 5 is Puma. I want to put a logo according to the category. How can I do it? Thank you for the help. Link to comment Share on other sites More sharing options...
rocky Posted January 6, 2010 Share Posted January 6, 2010 Add the following code before the $smarty->display at the bottom of product.php: $category = new Category($product->id_category_default); $category_link = $link->getCatImageLink($category->link_rewrite, $category->id_image, 'medium'); $smarty->assign(array('category_name' => $category->name[intval($cookie->id_lang)], 'category_link' => $category_link)); Then add the following code somewhere in product.tpl in your theme's directory to display the category image: This code assumes you have set up the default category of the product to be the category whose image you want to display. Link to comment Share on other sites More sharing options...
metta Posted January 6, 2010 Author Share Posted January 6, 2010 Add the following code before the $smarty->display at the bottom of product.php: $category = new Category($product->id_category_default); $category_link = $link->getCatImageLink($category->link_rewrite, $category->id_image, 'medium'); $smarty->assign(array('category_name' => $category->name[intval($cookie->id_lang)], 'category_link' => $category_link)); Then add the following code somewhere in product.tpl in your theme's directory to display the category image: This code assumes you have set up the default category of the product to be the category whose image you want to display. Thank you very much for the codes Rocky,I have my images named 3-exsmall.jpg, 4-exsmall.jpg, and 5-exsmall.jpg in a folder path:root/img/c/. How do I set the path to the images? Thank you very very much for the help. Link to comment Share on other sites More sharing options...
rocky Posted January 6, 2010 Share Posted January 6, 2010 I think you should just be able to change the parameter 'medium' above to 'exsmall'. 1 Link to comment Share on other sites More sharing options...
metta Posted January 6, 2010 Author Share Posted January 6, 2010 I think you should just be able to change the parameter 'medium' above to 'exsmall'. I got it. Thank you very much for the help. Link to comment Share on other sites More sharing options...
outlet.ee Posted May 16, 2010 Share Posted May 16, 2010 Rocky,how could I enable the category image to be different according to the language? There are default images like 'en-default-category.jpg', I'd like to have some text images for bettertogether module. So I created images like 'en-6-category' and fr-6-category' but I don't know how to make it so show them accordingly. Thank you! Link to comment Share on other sites More sharing options...
rocky Posted May 16, 2010 Share Posted May 16, 2010 To do that with friendly URLs turned off would be easy, since you can just add {$lang_iso}- before the image links. To do that with friendly URLs turned on would be difficult though, since you'd have to modify the .htaccess file to redirect the language to the right images. I'm not exactly sure how to do that. Link to comment Share on other sites More sharing options...
outlet.ee Posted May 16, 2010 Share Posted May 16, 2010 Thank you.Is it possible to do using static images, since there are a few categories involved only? Something like 'if category = 1 display src image={$lang_iso}-1-default.jpg'. Link to comment Share on other sites More sharing options...
rocky Posted May 17, 2010 Share Posted May 17, 2010 Yes, that would work. You'll need to change line 39 of category.tpl from: <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" /> to: <img src="{if $subcategory.id_category == 2 OR $subcategory.id_category == 3}{$base_dir}img/c/{$lang_iso}-{$subcategory.id_category}-default.jpg{else}{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}{/if}" alt="" /> This code will create static links for subcategories 2 and 3 and use the default dynamic links for the other subcategories. Link to comment Share on other sites More sharing options...
outlet.ee Posted May 17, 2010 Share Posted May 17, 2010 Oh, I am sorry, looks like I described my problem wrong. I need some different images for every language to be shown at certain categories (which are on promotion) above the breadcrumb, and show nothing on other categories. So I tried to use your code getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}{/if}" alt="" /> and it is trying to load mysite.com/-medium/.jpg.Looks like there is something wrong quoting the code, I used the one you suggested to change it to. Link to comment Share on other sites More sharing options...
outlet.ee Posted May 17, 2010 Share Posted May 17, 2010 Worked it out now - I had to add the following code to category.tpl: {if $category->id_category == 2}id|escape:'htmlall':'UTF-8'}-{$lang_iso}.jpg" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" /> {elseif $category->id_category == 3} id|escape:'htmlall':'UTF-8'}-{$lang_iso}.jpg" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" /> {else} {/if} So now the categories 2 and 3 show specified images for each language and other categories show none. Link to comment Share on other sites More sharing options...
Recommended Posts