Jump to content
  • 0
xrdm

Different template for product page depending on the category

Question

Hi there,

do you know how, in prestashop 1.7.x, show a different product tpl if the product child of a unique category?

eg.: I wish to display a different product gallery effect and text for all product pages that are in a specific category.

Thanks

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

You could have just one templete file and use conditional statements inside based on category ID.

Something like:

{if $product.id_category_default == 5}

//some code

{/if}

Or maybe add the category id as a class and do something via css, like:

<section id="main" class="category-{$product.id_category_default}" itemscope itemtype="https://schema.org/Product">

....

Edited by horiatb

Share this post


Link to post
Share on other sites
  • 0
On 31/1/2018 at 3:50 PM, horiatb said:

You could have just one templete file and use conditional statements inside based on category ID.

Something like:

{if $product.id_category_default == 5}

//some code

{/if}

Or maybe add the category id as a class and do something via css, like:

<section id="main" class="category-{$product.id_category_default}" itemscope itemtype="https://schema.org/Product">

....

 

thank you horiatb!

The first solution is good for me :)

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
  • 0
On 31/1/2018 at 3:50 PM, horiatb said:

You could have just one templete file and use conditional statements inside based on category ID.

Something like:

{if $product.id_category_default == 5}

//some code

{/if}

Or maybe add the category id as a class and do something via css, like:

<section id="main" class="category-{$product.id_category_default}" itemscope itemtype="https://schema.org/Product">

....

 

@horiatb

Do you know how to show different layout (include different partial product list) depending on category id in a module on homepage?  (prestashop 1.7)

I've a module on homepage that list products including {include file="catalog/_partials/miniatures/product.tpl" product=$product}
How can I say it to include a different tpl if it have to list items in category 15?

thanks

 

 

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

×

Important Information

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