I am using M2.3.4. I want to display shop by sidebar only on last child of the parent category.
Please suggest.
Solved! Go to Solution.
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!
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!
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!
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.
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!
Thank you Nishu Jindal it is now solved. Many many thanks