Magento: Removing Blocks from Footer on CMS Pages
In Magento, you can easily remove blocks like recently viewed products or newsletter signup from the footer of your CMS pages using the layout XML file. Let’s dive into how to achieve this step-by-step.
Understanding Your Current Setup
You’ve already included the block rendering in your footer.phtml file:
<?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>
<?php echo $this->getChildHtml('footer.newsletter') ?>
And you’re successfully hiding the breadcrumbs using a custom layout update:
<reference name="root">
<remove name="breadcrumbs" />
</reference>
Removing Specific Blocks from the Footer
To remove specific blocks, we need to identify their names and use the appropriate XML syntax.
1. Finding the Block Names
In your case, the block names are:
reports.product.viewedfor the recently viewed productsfooter.newsletterfor the newsletter signup form (assuming it’s a footer child block)
2. Using the Correct Syntax to Remove Blocks
The correct way to remove these blocks from the footer is as follows:
<reference name="footer">
<remove name="reports.product.viewed" />
<remove name="footer.newsletter" />
</reference>
This tells Magento to remove the specified child blocks (reports.product.viewed and footer.newsletter) from the footer layout.
Implementing in Your CMS Page
To apply this change, go to your CMS page in the Magento admin panel. Navigate to the Design section under the page’s Configuration tab. In the Custom Layout Update XML field, paste the following code:
<reference name="footer">
<remove name="reports.product.viewed" />
<remove name="footer.newsletter" />
</reference>
Save your changes and preview or refresh your CMS page.
What If Your Blocks Are Named Differently?
If you need to remove different blocks, the process remains the same. Simply replace reports.product.viewed and footer.newsletter with the names of your specific blocks.
Remember that block names can be found in the layout XML files (usually located under app/design/frontend/base/default/layout) or by inspecting the page source code while Magento is running.
Conclusion
Removing blocks from the footer of a CMS page in Magento involves identifying the block names and applying them to the custom layout update XML. The key is using the correct syntax (<remove name="block_name" />) within the footer reference section.
Don’t forget that you can find more detailed guides on working with Magento layouts, including examples and best practices, at LaravelCompany.
Happy coding!