Jump to content
melas

[SOLVED] how to use Different Template for every category!

Recommended Posts

Hi everybody!

 

 

I'm new in the prestashop community, and

 

I would like to ask you something

 

 

Is there any way to appear in every category different template?

 

 

Thank You!

 

 

 

Share this post


Link to post
Share on other sites

yes it is possible but in this case you will have to change several things:

controllers, and also .tpl & css files.

 

in CategoryController.php file located in: controllers/front/ directory you've got initContent() function with code:
 

$this->setTemplate(_PS_THEME_DIR_.'category.tpl');

you need to define different template file for categories, for example:

if ($this->category->id==5){
$this->setTemplate(_PS_THEME_DIR_.'category-for-id-5.tpl'); // template file for caregory id: 5
} else {
$this->setTemplate(_PS_THEME_DIR_.'category.tpl'); // DEFAULT template
}
  • Like 6

Share this post


Link to post
Share on other sites

Thank you for  your advice, it was very helpfull !!!!!!!!

 

I think that I undestand what I have to do!

 

Thank you very much!

Share this post


Link to post
Share on other sites

in addition to what i said above, remember, that in category.tpl you've got additional .tpl files like product-list.tpl etc.

if you want to customize separate pages, you need to include these files, or other - modified files

 

im going to mark this topic as solved

 

best regards

  • Like 1

Share this post


Link to post
Share on other sites

awsOme.

 

hello

may i know what ps version you use? and solution above solved your issues too?

Share this post


Link to post
Share on other sites

Hi there,

 

i got the same issu but i need to get different themes per CMS page. You can tell me if that is possible,

and maybe you got an idea on how to do that?

 

Thx a lot.

Toby

Share this post


Link to post
Share on other sites

Hi Vekia

 

Your fix woks great to get different template based on category ID but how to get templates products to use the same template as the category they belong to?

 

Thanks

 

Pat

 

version 1.6.9

Edited by ventesites (see edit history)

Share this post


Link to post
Share on other sites

if i need to make different templates for different groups of categories

example: categories id 5,6,7,8 use template1.tpl, categories id 9,10,11 use template2.tpl and all the rest use default.tpl

Edited by vadimda (see edit history)

Share this post


Link to post
Share on other sites

found a solution after reading php docs

		if ($this->category->id==4 || $this->category->id==8 || $this->category->id==5){
			$this->setTemplate(_PS_THEME_DIR_.'category1.tpl');
		} elseif ($this->category->id==9 || $this->category->id==10 || $this->category->id==11){
			$this->setTemplate(_PS_THEME_DIR_.'category2.tpl');
		} else {
			$this->setTemplate(_PS_THEME_DIR_.'category.tpl');
		}
  • Like 1

Share this post


Link to post
Share on other sites

in addition to what i said above, remember, that in category.tpl you've got additional .tpl files like product-list.tpl etc.

if you want to customize separate pages, you need to include these files, or other - modified files

 

im going to mark this topic as solved

 

best regards

Hi vekia

 

is it possible to setup for the price drop  different pages for each category?

 

I would to show the promotions articles in different pages for man, woman and not in only one page.

 

thanks

Angela

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More