Hiding Category Titles on Magento Category Pages
In Magento, category pages display the title of the selected category by default when you apply static blocks to them. However, sometimes you might want to hide this title for specific design needs or to improve the user experience. Here’s how you can achieve this.
Understanding the Default Behavior
By default, Magento includes the category title as part of its page layout XML file (page.xml). This is why you see the category name at the top of each category page. The relevant code snippet looks like this:
<block type="page/html_head" name="head" as="head">
<action method="setTitle" translate="title"><title><![CDATA[Category Title]]></title></action>
</block>
Modifying the XML Layout
To hide the category title, you need to modify the page layout XML file. You can do this via a custom extension or by directly editing the core files (though we strongly recommend using an extension for maintainability and upgrade compatibility).
- Using a Custom Extension:
Create a new module in your Magento setup. In the
app/code/local/YourCompany/YourModule/etcdirectory, create a layout XML file calledcatalog.xml. Add the following code:
<layout version="1.0">
<catalog_category_view>
<reference name="head">
<action method="unsetChild"><name>title</name></action>
</reference>
</catalog_category_view>
</layout>
This tells Magento to remove the ‘title’ block from the category view page.
- Directly Editing Core Files:
Edit
app/code/core/Mage/Page/etc/page.xmland find the<block type="page/html_head" name="head">section. Add the following line inside it:
<action method="unsetChild"><name>title</name></action>
Applying the Changes
After making these modifications, clear your cache in Magento (System > Cache Management > Flush Magento Cache).
Now, when you visit a category page with static blocks applied, you should no longer see the category title. Only the content of your selected static block will be displayed.
Remember, editing core files directly is not recommended for long-term maintenance or upgrade purposes. It’s always better to use custom extensions and layout updates to ensure your changes remain valid after Magento updates.
Additional Considerations
If you have other pages where you want to hide titles, such as CMS pages with static blocks, you can follow a similar approach using the php/cms_index_index handle instead of catalog_category_view.
For more detailed guides on Magento layout XML customization and extension development, visit our comprehensive Magento Development Resources page at Laravel Company. We provide extensive tutorials and best practices for working with this powerful e-commerce platform.
In conclusion, hiding category titles in Magento requires a basic understanding of the layout XML system. By following these steps, you can easily customize your store’s appearance to meet specific design needs without disrupting core functionality.