Magento - Re-ordering Block items

Magento has lots of blocks that display in the left and right columns (based on your layout). Changing the order in which they are displayed or sorted is easy. Navigate to the folder "app\design\frontend\default\YOUR_THEME\layout". In this folder, there are several XML files which are called Layouts.

Magento Layouts are the tools with which you can assign content blocks to each structural block you create. Layout exists in the form of XML text-file and by modifying the layout you are able to move blocks around in a page and assign templates to the content blocks to produce markup for the structural blocks.

To change the order, find a block you want to change. So if I wanted to display the products compared side box first in my left column, I would do by adding before="-" as an attirbute to it's xml node. Now, save it and upload. That's it!

<reference name="left">
    <block type="core/template" before="-" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
</reference>

Here some other ways to order blocks.

To display as the First block:

before="-"

To display as the last block:

after="-"

To display before any other block:

before="block_name"

To display after any other block:

after="block_name" 

13 comments for Magento - Re-ordering Block items

Dan's picture

Thanks so much for this post!...

Thanks so much for this post! You saved my life! This totally makes sense now Smile

Christopher Balchin's picture

Cleared up the problem I had...

Cleared up the problem I had in seconds! Thanks for the useful post Smile

Richard's picture

Christopher, Glad I can help!...

Christopher, Glad I can help!

Tom's picture

Thanks!! It's so simple once...

Thanks!! It's so simple once you know it Smile.

Diego's picture

Thanks a lot man!!...

Thanks a lot man!!

Richard's picture

Thanks!...

Thanks!

Hisham's picture

Thanks a lot Richard, one...

Thanks a lot Richard, one question. i have Most Popular blocks on the left display more than 10 products how can i make it only 5?

Michael Price's picture

I have been looking all over...

I have been looking all over for this... I am too used to working with OsCommerce I think. Thanks for the help here.

Michael Price's picture

A great help thank you....

A great help thank you.

SEO Leeds's picture

Thank you so much for this,...

Thank you so much for this, it can save me a lot of time brilliant.

Vintage Man's picture

Very helpful with magento...

Very helpful with magento core blocks, how do I get this to work with custom blocks, I want the tags block to appear last in my left column, I changed the layout file to read;


refreshed and dumped cache, block still not appearing after the left_column_payment block?

Any help would be appreciated.
thanks

Vintage Man's picture

Would be able to tell me how...

Would be able to tell me how to set order of a widget in the felt column?

thanks

Twin's picture

Your site contain a many...

Your site contain a many useful information, thanks.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.