Magento: Display Block After Category Description
Are you facing issues while trying to place a block right after the category description on your Magento store’s category page? You’ve come to the right place! In this post, we’ll guide you through the process of rearranging your layout XML file to achieve the desired order.
Understanding Your Current Layout XML File
Let’s first understand what your current catalog_category_layered.xml layout XML file does. It removes some default blocks and adds your custom block (amshopby/catalog_layer_view_top) before the content area of the category page:
<catalog_category_layered>
<remove name="catalog.leftnav" />
<remove name="enterprisecatalog.leftnav"/>
<reference name="left">
<block type="amshopby/catalog_layer_view" name="amshopby.navleft" after="currency" template="catalog/layer/view.phtml"/>
</reference>
<reference name="content">
<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="-" template="amshopby/view_top.phtml"/>
<block type="amshopby/top" name="amshopby.top" before="category.products" template="amshopby/top.phtml"/>
</reference>
</catalog_category_layered>
The line <block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="-" template="amshopby/view_top.phtml"/> places your custom block at the beginning of the content area, right after the category title but before the category description.
The Desired Layout Rearrangement
You want to rearrange the layout so that it follows this order:
- Category Title
- Category Description
- Custom Block (filtered navigation)
- Product Overview
To achieve this, you need to move your custom block after the category.products block and before the product listing.
Moving Your Custom Block After the Category Description
To place your custom block right after the category description, update your layout XML file as follows:
<catalog_category_layered>
<remove name="catalog.leftnav" />
<remove name="enterprisecatalog.leftnav"/>
<reference name="left">
<block type="amshopby/catalog_layer_view" name="amshopby.navleft" after="currency" template="catalog/layer/view.phtml"/>
</reference>
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<!-- Your existing code for product_list, etc. -->
</block>
<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="product_list_toolbar" template="amshopby/view_top.phtml"/>
</reference>
</catalog_category_layered>
Notice the change in your custom block’s placement:
<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="product_list_toolbar" template="amshopby/view_top.phtml"/>
We’ve added before="product_list_toolbar" to specify that the custom block should be placed right before the product listing (product_list_toolbar).
Conclusion
In this post, we explored how to display a custom Magento block after the category description on your store’s category page. By updating your layout XML file and specifying the appropriate placement for your custom block, you can achieve the desired order of elements.
Remember to always keep your theme code clean and well-organized for easier maintenance in the future. For more advanced Magento development topics and best practices, feel free to explore our blog at https://laravelcompany.com.