kwagsthlm Posted June 26, 2013 Share Posted June 26, 2013 I want to publish a specific category plus category picture. No module, just a piece of code to put into my template such as: {if $category->id_image} <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" /> {/if} How do I manage it? Thanks in advance! Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 26, 2013 Share Posted June 26, 2013 Hi, you want display different images on catalog and home page, am I right? But category object has only one picture, and without any code modifications you can not do it. Regards 1 Link to comment Share on other sites More sharing options...
vekia Posted June 26, 2013 Share Posted June 26, 2013 it's because you haven't got defined $category variable, you need to put $category definition into the front controller smarty array (via assign) Link to comment Share on other sites More sharing options...
kwagsthlm Posted June 26, 2013 Author Share Posted June 26, 2013 it's because you haven't got defined $category variable, you need to put $category definition into the front controller smarty array (via assign) How can I accomplish that? Would you like to assist with an example or link? Link to comment Share on other sites More sharing options...
vekia Posted June 26, 2013 Share Posted June 26, 2013 where you want to display picture? everything depends on that Link to comment Share on other sites More sharing options...
kwagsthlm Posted June 26, 2013 Author Share Posted June 26, 2013 where you want to display picture? everything depends on that In homefeatured.tpl 1 Link to comment Share on other sites More sharing options...
vekia Posted June 26, 2013 Share Posted June 26, 2013 so you can easily edit the homefeatured.tpl file, you've got there: $this->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), )); add there 'category' => New Category (id), where the id is an ID of category. code: $this->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'category' => new Category(id), )); Link to comment Share on other sites More sharing options...
kwagsthlm Posted June 26, 2013 Author Share Posted June 26, 2013 Those lines of code does not exist in my "homefeatured.tpl" template file. Can not manage to get it to work. Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 26, 2013 Share Posted June 26, 2013 I think vekia means that you should edit the homefeatured.php with code above, after that you can use category object in your template file. 1 Link to comment Share on other sites More sharing options...
kwagsthlm Posted June 26, 2013 Author Share Posted June 26, 2013 so you can easily edit the homefeatured.tpl file, you've got there: $this->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), )); add there 'category' => New Category (id), where the id is an ID of category. code: $this->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'category' => new Category(id), )); I think vekia means that you should edit the homefeatured.php with code above, after that you can use category object in your template file. Ok, that make some diffrence, thanks! I get it to work when I change the code in the core file, but not when I try to change it for my specific theme. Any suggestions on that? (Have cleared the cache folder) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 26, 2013 Share Posted June 26, 2013 Only .tpl files can be moved in your theme folder, for .php file this trick isn't works Link to comment Share on other sites More sharing options...
kwagsthlm Posted June 26, 2013 Author Share Posted June 26, 2013 Only .tpl files can be moved in your theme folder, for .php file this trick isn't works If you wanted to accomplish the same thing, you would change the way I tried now? Or should I learn how to create a module. I am new to Prestashop as you can imagine. Link to comment Share on other sites More sharing options...
vekia Posted June 26, 2013 Share Posted June 26, 2013 if you're editing module php file - you should edit file located in the module directory (not in theme - because it doesn't work) you can override .tpl files for modules, not .php Link to comment Share on other sites More sharing options...
Recommended Posts