Magento: Adding Footer Links Without Affecting Top Navigation
Dear Fiona,
Thank you for reaching out regarding your Magento navigation dilemma. I understand that you want to add links to your store’s footer without them appearing in the top navigational menu as well. Let me guide you through this process.
The Problem with Default Magento Setup
In a typical Magento installation, CMS static blocks are not restricted to specific areas of the website by default. This is why when you edit the ‘Footer Links’ block under CMS > Static Blocks and add new links, they will appear on all pages including your top navigation menu.
Understanding Magento’s Layout Structure
To resolve this issue, we need to understand how Magento manages layout structures using XML layouts. Every page in Magento has a corresponding XML file that defines which blocks should be displayed where.
The main XML files for the frontend are located under <your_magento_root>/app/design/frontend/<vendor>/<theme>/layout/. For default Magento themes, you’ll find them under app/design/frontend/base/default/layout/.
Customizing Footer Links Only
To add links to your footer without affecting other navigation areas, follow these steps:
-
Create a new static block: Go to CMS > Static Blocks and create a new block with an identifier like
footer_links. Add your desired links in this block. -
Check if the block is already defined in XML layouts: Open
<your_magento_root>/app/design/frontend/<vendor>/<theme>/layout/default.xml(ordefault.xmlunder the default theme folder). Search for a node namedfooter_links. If it exists, proceed to step 3. If not, you’ll need to create it.
<!-- footer_links -->
<block type="cms/block" name="footer_links" as="footer_links">
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
<!-- Add this new block to your footer area -->
<reference name="footer_links">
<block type="cms/block" name="footer_links" before="-">
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
</reference>
- Clear the cache: Once you’ve added or modified your XML files, Magento needs to recompile its layout XMLs and clear the cache. You can do this in the Magento admin by navigating to System > Cache Management and selecting all options except ‘Configuration’ and ‘Layout XML files’. Click ‘Flush Cache Storage’.
Conclusion
By following these steps, you’ve successfully isolated your footer links into their own block. This ensures that they only appear in the footer area without disrupting other navigation menus on your site.
Remember, Magento themes are highly customizable. If you’re using a third-party theme or have a complex layout structure, you might need to modify additional XML files or even customize your theme’s phtml templates to achieve the desired output.
For more advanced layout customization in Magento 2, I recommend checking out our comprehensive guide on Magento Layout XML Reference.
If you encounter any further issues or need assistance with other Magento development tasks, feel free to reach out! We’re always here to help.
Best, [Your Name]