morrisa Posted February 1, 2015 Share Posted February 1, 2015 I'm using PrestaShop 1.6.0.9. I need to override the default category layout for specific category IDs and have created an override CategoryController.php to do this. I need to change the default_subcat image to another of a different size that I have set up. For specific category IDs I am executing $this->setTemplate(_PS_THEME_DIR_.'category-type2.tpl'); I believe that this code is being executed as if I put "print $this->category->id;" in the same block, the category IDs of those I would like to override is shown at the top of the page. However, it seems that the default category template is being used and that the override is not effective. I cannot see any errors or other messages, just the category ID being displayed for the specific categories I need to override. Why might this be? I have cleared the cache several times. Any help would be much appreciated! Thanks, Alan Link to comment Share on other sites More sharing options...
NemoPS Posted February 2, 2015 Share Posted February 2, 2015 How did you override it? It might get overridden itself by its parent. You might want to try this out as well: http://nemops.com/prestashop-upgrade-safe-template-modifications/ Link to comment Share on other sites More sharing options...
morrisa Posted February 2, 2015 Author Share Posted February 2, 2015 Nemo1, In /override/controllers/front I created CategoryController.php and in there added: class CategoryController extends CategoryControllerCore { // array with the selected categories private $customCategories = array(1051, 1052, 1053); public function init() { parent::init(); if (in_array($this->category->id, $this->customCategories)) { print $this->category->id; $this->setTemplate(_PS_THEME_DIR_.'category-type1.tpl'); } } } I know that the logic goes through the block of code that sets the category template as the category ID is printed at the top of the rendered page. What I don't know if when this code is executed in relation to parent - is it before, instead of, or after? I've been able to get the template switch to take place by adding the code to /controllers/front/CategoryController.php, but would rather not do this. Thanks for the link to the page discussing overrides - I'll have a look at this. Alan Link to comment Share on other sites More sharing options...
NemoPS Posted February 4, 2015 Share Posted February 4, 2015 Please check the link. In any case you are overriding the wrong method, it should be initContent 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