Change order of blocks via local.xml file

Change order of blocks via local.xml file

August 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Change order of blocks via local.xml file

Reordering Existing Blocks via Local.xml in Magento

As a seasoned Magento developer, I often receive queries about managing and reordering blocks in the local.xml file. While you can easily control block placement during initial setup with attributes like before or after, changing these for existing blocks requires a slightly different approach.

Understanding Block Placement Mechanics

In Magento, block order is determined by the layout XML files—specifically, the local.xml and page_layout.xml files located under app/design/frontend/[your_package]/[your_theme]/layout. These files define where each block appears on the page using attributes like reference, block, and as.

For example, let’s consider a common scenario: you want to move the layered navigation block below the newsletter subscription block in the left column.

Changing Block Order for Existing Blocks

To reorder existing blocks via local.xml, you need to identify their current positions first. Open your local.xml file (or create it if not present) and look for any reference attributes that correspond to the blocks you want to move. For instance:

<reference name="left">
    <block type="newsletter/subscribe" name="newsletter_subscription" before="-">
        ...
    </block>
</reference>

In this example, the newsletter subscription block is placed at the top of the left column (before="-" means it’s the first element in the container).

Now, let’s move the layered navigation block after it. You’ll need to update your local.xml:

<reference name="left">
    <block type="catalog/layer_view" name="catalog.leftnav" after="newsletter_subscription"/>
</reference>

Here, I’ve added a new block element for the layered navigation and set its after attribute to match the name of the newsletter subscription block (i.e., newsletter_subscription).

This tells Magento to place the layered navigation block immediately following the existing newsletter subscription block in the left column.

Best Practices: Reordering Blocks

Before you start moving blocks around, keep these best practices in mind:

  • Be careful with naming: Ensure your block names are unique and descriptive. This helps prevent conflicts and makes maintenance easier.
  • Avoid nested blocks: While possible, placing blocks inside other block elements can lead to complexity and potential display issues.

Conclusion: Reordering Blocks for a Better User Experience

Reordering existing blocks via the local.xml file is a powerful way to fine-tune your Magento store’s layout. By carefully managing block placement, you can create intuitive navigation structures and enhanced user experiences.

Remember, it’s essential to backup your files before making changes, especially if you’re not familiar with the specific block you’re moving.

If you need more advanced customizations or encounter any issues, don’t hesitate to reach out to our expert Magento development team at Laravel Company. We’re always ready to help you optimize your e-commerce platform for maximum performance and customer satisfaction.

Themes Configuration Orders

Our network