Categories

Featured templates

Magento. How to change blocks order

Judy Waters November 18, 2015
Rating: 5.0/5. From 4 votes.
Please wait...

This tutorial shows how to change blocks order in Magento templates.

Magento. How to change blocks order

Sidebar blocks can be rearranged in one of the template files. Use either FTP or hosting cPanel to reach it. Open the following file on server /app/design/frontend/tm_themes/themeXXX/layout/local.xml. Use any HTML editor to check its content, locate the following piece of code:

    <reference name="left">
            <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" after="catalog.leftnav">
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                    <label>Shopping Cart Sidebar Extra Actions</label>
                </block>
            </block>
        </reference>
    

Update the reference name to be <reference name="left_first">:

Magento_How_to_change_blocks_order_1

This allows using before="-" and after="-" tools to reorder the sidebar blocks. Insert the actual block name instead of hyphen.

Let’s reorder ‘Shop By’ and ‘My Cart’ blocks as an example:

  1. Locate the following line in the local.xml file: <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">

    <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">

    before="-"is the value to update.

  2. Specify if you want to have cart before or after the Shop By filter. Let’s put it after Shop By filter. Code should be eventually updated as follows:

    <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" after="catalog.leftnav">

    Magento_How_to_change_blocks_order_2

The same values can be changed for other sidebar blocks. Update the file once all modifications are applied.

Note: you might need to rebuild the index and clear cache to apply the changes.

Get back to the category page and refresh it. Sidebar blocks have been successfully reordered.

Feel free to check the detailed video tutorial below:

Magento. How to change blocks order

Magento Templates
This entry was posted in Magento Tutorials and tagged block, Magento, order. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket