I have a custom module and on that I have a template file. I want to show that template in a particular category instead of it displaying in all the category pages.
How can I achieve that?
Anyone please suggest me to achieve this result?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI have a custom module and on that I have a template file. I want to show that template in a particular category instead of it displaying in all the category pages.
How can I achieve that?
Anyone please suggest me to achieve this result?
For that, you just need to create one static block and call you .phtml
file like the below example.
{{block class="\Magento\Framework\View\Element\Template" template="Vendor_Module::product/category_customdata.phtml"}}
Then you just need to call these blocks in a specific category. Check below image for your reference.
That's it.
I hope it helps you.
You can try to load block with template with
catalog_category_view_id_[Cat Id].xml
Reference with similar question:
https://stackoverflow.com/questions/36451706/magento2-multiple-category-layouts?rq=1
- Create CMS block
{{block class="Magento\Framework\View\Element\Template" name="formblock" template="Vendor_Module::myfiles/myfile.phtml"}}
- In your category, set that CMS block.