clanger Posted April 5, 2012 Share Posted April 5, 2012 Hello Everyone, First time poster and I'm not that great with PHP. I know bits and pieces and can usually figure code out by looking it over. What I am trying to accomplish is have a category page that has a different theme than the rest of them. I have created a category2.php and CategoryController2.php as well as category2.tpl When calling on www.xxxxx.com/category2.php?id_category=1 for example, I get redirected to www.xxxxx.com/category.php which is displaying error: There is 1 error : Missing category ID Any advice? Thanks in advance. Link to comment Share on other sites More sharing options...
Dh42 Posted April 6, 2012 Share Posted April 6, 2012 This is a bulkier way of doing it, but this is what I do in a situation like that. This is in pseudo code also if category ==12 new category html else regular category html /if I just append the category.tpl and use an if statement in it to decide what to show. So then everything is in one file and you are not modifying anything more than the template. A little more code overhead on your server, but it is really not an issue. Link to comment Share on other sites More sharing options...
clanger Posted April 7, 2012 Author Share Posted April 7, 2012 Where would I put this code, and is this exactly what I put? Just change the category number to match the page I want? Thanks so much in advance, this seems so much easier Link to comment Share on other sites More sharing options...
clanger Posted April 7, 2012 Author Share Posted April 7, 2012 I would really really appreciate a little help in this. This is the last thing that I need to figure out and I am good to go. Thank you in advance. Link to comment Share on other sites More sharing options...
clanger Posted April 10, 2012 Author Share Posted April 10, 2012 I am assuming that something would have to be added to this section of the categorycontroller? public function displayContent() { parent::displayContent(); self::$smarty->assign('categoryNameComplement', ''); self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); } Any help at all is GREATLY appreciated. Link to comment Share on other sites More sharing options...
Dh42 Posted April 10, 2012 Share Posted April 10, 2012 I was actually talking about doing the check inside of the category.tpl file. It really actually depends on how much modification you are trying to do as to where you need to put it. Link to comment Share on other sites More sharing options...
clanger Posted April 10, 2012 Author Share Posted April 10, 2012 I just need to have a seperate category.TPL file so I can theme it differently. It won't have the left colums, right column, etc. Basically just have the products and some text aroud the page that will be updated from time to time. Link to comment Share on other sites More sharing options...
clanger Posted April 14, 2012 Author Share Posted April 14, 2012 "Bump" I would almost pay someone to help me get this working at this point. Link to comment Share on other sites More sharing options...
clanger Posted April 18, 2012 Author Share Posted April 18, 2012 Bump.......I beg of you, anyone. I know this would be simple to do, I just don't have the ability. Link to comment Share on other sites More sharing options...
C@Miltec Posted May 25, 2012 Share Posted May 25, 2012 I am currently trying to get one category to load a different category.tpl file based on the category id so I have edited CategoryController.php and changed public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); } } to public function displayContent() { parent::displayContent(); if ($_GET['id_category']) $category = $_GET['id_category']; else if ($_GET['id_product']) { $product = new Product($_GET['id_product']); $category = $product->id_category_default; } self::$smarty->assign('category', $category); if(($category) == '2') self::$smarty->display(_PS_THEME_DIR_.'category2.tpl'); else self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); } } But now it appears that neither category.tpl nor category2.tpl will load, every thing else is fine though. As for having a category page without the left column and right colum, you would need to load a different header.tpl for the left and a different footer.tpl for the right, I have managed to get that to work using basically the code above in frontcontroller.php Link to comment Share on other sites More sharing options...
codegrunt Posted May 28, 2012 Share Posted May 28, 2012 First, *NEVER* edit core files. You should not have to, you can use class overrides for this purpose (look at "/overrides"). Second, you have no guarantee that the category ID is being passed by GET nor should you have to worry about that. It will be set properly when CategoryController::process() is called. So instead use the category object itself to test against: public function displayContent() { parent::displayContent(); self::$smarty->assign('categoryNameComplement', ''); if($this->category->id_category=1234) { self::$smarty->display(_PS_THEME_DIR_.'category1234.tpl'); } else { self::$smarty->display(_PS_THEME_DIR_.'category.tpl'); } } Cheers 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