Remove top navigation using ifconfig in magento

Remove top navigation using ifconfig in magento

September 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Remove top navigation using ifconfig in magento

Removing Top Navigation in Magento Using Ifconfig

Magento provides powerful configuration options that allow you to control various aspects of your store’s behavior. One such option is the ifconfig directive, which enables conditional logic based on configuration settings.

In this guide, we’ll explore how to use ifconfig to remove the top navigation bar in Magento when a specific module is enabled.

Understanding Ifconfig

The ifconfig directive allows you to add or remove elements from XML layout files based on whether a specified configuration value is set. Here’s the basic syntax:

<reference name="container">  <!-- The container that holds the element -->
    <action method="addItem" ifconfig="namespace/key/enabled">   <!-- The condition and action -->
        <type>element_type</type>
        <name>element_name</name>
    </action>
</reference>

Removing Top Navigation Using Ifconfig

You’re on the right track! To remove the top navigation using ifconfig, you’ll need to target the specific container that holds the navigation elements. In Magento, the top navigation is typically placed inside a <catalog.topnav> container.

Here’s how to do it:

  1. Locate your module’s XML layout file (usually found in app/code/[Vendor]/[Module]/etc/frontend/layout/your_layout.xml).

  2. Add the following code within the <layout> element:

<reference name="catalog.topnav" remove="true" ifconfig="advancemenu/general/enabled"/>
  1. Save the file and clear your cache.

How It Works

This configuration tells Magento to remove the catalog.topnav container from the layout if the advancemenu/general/enabled setting is enabled (i.e., set to 1).

Remember, the ifconfig directive checks for the existence of the specified key. If it exists and has a truthy value (1), the action is performed. In this case, the top navigation will be removed.

Best Practices

When working with ifconfig, always ensure that:

  • The configuration path (namespace/key/enabled) matches exactly.
  • The container name is correctly identified.
  • You clear Magento’s cache after making layout changes.
  • Your XML files are properly formatted and validated.

Conclusion

Using the ifconfig directive, you can easily remove or add elements to your Magento store’s layout based on specific configuration settings. In this case, we’ve demonstrated how to remove the top navigation bar when a particular module is enabled.

This approach provides a clean and elegant way to manage complex conditional logic in your Magento store without resorting to more invasive methods like overriding core templates or controllers.

To learn more about Magento development best practices and advanced customization techniques, visit Laravel Company’s Magento tutorials for comprehensive guides and real-world examples.

Catalog Extensions Themes Configuration

Our network