Removing the Left Column on Product Listing Pages in Magento
Magento’s default product listing pages include a left column that displays filters like category, price range, etc. If you want to remove this left column for a cleaner look, or optimize it for mobile devices, here’s how to do it.
Understanding the Layout Structure
The layout structure of the product listing page is defined in the catalog_category_view.xml file located under app/design/frontend/[package]/[theme]/layout. The relevant code snippet that defines the left column looks like this:
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" before="-" template="catalog/navigation/left.phtml"/>
</reference>
In this XML structure, name="left" refers to a container called ‘Left’. The catalog/navigation block is placed inside it using the before="-" attribute.
Removing the Left Column
To remove the left column completely, you just need to comment out or delete these lines from your layout file:
<!--
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" before="-" template="catalog/navigation/left.phtml"/>
</reference>
-->
After commenting it out, save the changes. Now, if you go to your product listing page, you’ll notice that the left column has disappeared.
Customizing the Left Column
If you want to keep some content in the left column but remove others, you can customize what’s displayed there. Here are a few options:
-
Edit the Template: The template file for the left navigation is
catalog/navigation/left.phtml. You can edit this file directly to modify what’s shown. -
Use Magento’s Layout XML: You can add or remove blocks inside the ‘Left’ container using layout XML in your theme’s local.xml file like so:
<reference name="left">
<remove name="catalog.leftnav"/>
<block type="core/text_list" name="additional_left_blocks" as="additional_left_blocks">
<block type="your/module/block_name" template="path/to/your/template.phtml"/>
</block>
</reference>
Replace type="your/module/block_name" and template="path/to/your/template.phtml" with your own block and template details.
Conclusion
Removing the left column on a Magento product listing page is quite straightforward once you understand the layout structure. It’s an easy way to achieve a more streamlined look for your store, or to optimize it for smaller screens like mobile devices.
Remember, always make a backup of your files before editing them directly, especially if you’re not familiar with these changes. If you need assistance with any other Magento customizations or have questions about theme development, feel free to reach out to us at Laravel Company. We specialize in helping businesses make the most of their ecommerce platforms.
Happy coding!