cancel
Showing results for 
Search instead for 
Did you mean: 

How to show sidebar on last child category only of parent category ?

SOLVED

How to show sidebar on last child category only of parent category ?

I am using M2.3.4. I want to display shop by sidebar only on last child of the parent category. 

Please suggest.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to show sidebar on last child category only of parent category ?

Hi @radiantweb ,

 

I tried the same code in below phtml (In Vanilla Magento) and it is working fine at my end.

vendor/magento/theme-frontend-luma/Magento_LayeredNavigation/templates/layer/view.phtml

 

Can you please check are you using some Third-party extension for the layered Navigation. If yes, then you need to above condition in that module itself.

 

For Debugging: 

1. First, try to find out which module/file is rendering on the frontend for the layered navigation using Enable Template Path Hints for Storefront option in admin.

2. Then Try to override that file in the custom theme and add the above-mentioned condition.

 

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

View solution in original post

5 REPLIES 5

Re: How to show sidebar on last child category only of parent category ?

Hi @radiantweb 

Kindly refer below link for your issue:
https://magento.stackexchange.com/questions/201583/magento-2-add-static-block-on-category-page-left-...

Using suggested steps you can add side bar for specific category only.

It may help you!
Problem Solved ? Please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: How to show sidebar on last child category only of parent category ?

Hi @radiantweb ,

 

you can follow steps to show Layered navigation filter on the last category which don't have any child further using below steps:

 

1.  Copy the File in Theme:

vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml  

Copy to Theme Path

app/design/frontend/Smartwave/porto_child/Magento_LayeredNavigation/templates/layer/view.phtml 

  2. Add the Condition In the Phtml file on top to show content only if 

if($this->getLayer()->getCurrentCategory()):$subcategories=$this->getLayer()->getCurrentCategory()->getCategories($this->getLayer()->getCurrentCategory()->getId());
    /* count and check the category have any sub category */
    if($subcategories->count() <= 0){
}
endif;

 Wrap the Phtml code in the below condition and Layered Navigation will show only in the last category.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: How to show sidebar on last child category only of parent category ?

I tried this solution but it did not work for me. I already have Magento_LayeredNavigation folder within theme and wrapped condition but it did not work.

Re: How to show sidebar on last child category only of parent category ?

Hi @radiantweb ,

 

I tried the same code in below phtml (In Vanilla Magento) and it is working fine at my end.

vendor/magento/theme-frontend-luma/Magento_LayeredNavigation/templates/layer/view.phtml

 

Can you please check are you using some Third-party extension for the layered Navigation. If yes, then you need to above condition in that module itself.

 

For Debugging: 

1. First, try to find out which module/file is rendering on the frontend for the layered navigation using Enable Template Path Hints for Storefront option in admin.

2. Then Try to override that file in the custom theme and add the above-mentioned condition.

 

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: How to show sidebar on last child category only of parent category ?

Thank you Nishu Jindal it is now solved. Many many thanks Smiley Wink