Jump to content

[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

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
  • 2 weeks later...

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
  • 10 months later...
  • 2 months later...
  • 2 weeks later...

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
  • 2 weeks later...

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
  • 1 year later...

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