Jump to content

Different template for product page depending on the category


xrdm

Recommended Posts

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

Link to comment
Share on other sites

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

 

 

 

 

 

 

 

Link to comment
Share on other sites

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

 

 

  • Like 1
Link to comment
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...