Jump to content

Customize layout based on if faceted search or not


Recommended Posts

Right now for all of our category pages I'm using 2 column layout, small left column and larger right column. The left column shows the Filters (faceted search). The only problem is, some categories just have no filters because those filters just don't apply to that category. So I'm wondering, is there a way to make a conditional if/then statement somewhere to say basically, if faceted search, show 2 column layout, else show full width. Does anyone know if that's possible and if so which .tpl page would I add the code into?

Link to comment
Share on other sites

I'm using child theme of the classic theme, but I do have the faceted search module hooked, but I need it hooked so that when there are available filters it shows up. But the problem is, if there are no filters, then the filters don't appear, leaving the left column empty so it looks funny in some categories. 

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

You can use a different template for each category. 

In your theme :

1. Create a template that displays the list of products without the left column :

Copy the file ../catalog/listing/product-list.tpl to ../catalog/listing/product-list-full-width.tpl and change {extends file=$layout} to {extends file='layouts/layout-full-width.tpl'}

2. Create a template for each category :

Copy the file ../catalog/listing/category.tpl to ../catalog/listing/category-{id_category}.tpl (replace id_category with the category id) and change {extends file='catalog/listing/product-list.tpl'} to {extends file='catalog/listing/product-list-full-width.tpl'}

 

  • Thanks 2
Link to comment
Share on other sites

  • 4 weeks later...
On 3/7/2020 at 3:15 AM, fbenoist.com said:

Hi,

You can use a different template for each category. 

In your theme :

1. Create a template that displays the list of products without the left column :

Copy the file ../catalog/listing/product-list.tpl to ../catalog/listing/product-list-full-width.tpl and change {extends file=$layout} to {extends file='layouts/layout-full-width.tpl'}

2. Create a template for each category :

Copy the file ../catalog/listing/category.tpl to ../catalog/listing/category-{id_category}.tpl (replace id_category with the category id) and change {extends file='catalog/listing/product-list.tpl'} to {extends file='catalog/listing/product-list-full-width.tpl'}

 

So in step 2, would the file name be category-{55}.tpl ? or whatever the category id is? 

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...