Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

XML/Block Configuration
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Has anyone been successful in moving around blocks in the Layout XML’s?

I’ve managed to understand how to move them from column to column, via specifying “left” or “right” in the reference tag.  But I can’t understand how to change the ORDER in which they appear.  I noticed that the “before="-" tag has something to do it with, but whats the proper syntax for that?

For example:

<block type="catalog/layer_view" name="catalog.rightnav" before="-">

But what does before="-" mean?  And how do you set the order in which the blocks appear?

Anyone tackled this yet?  Magento Team?

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Update… (Someone tell me if this is wrong or not though) :

What I wanted was to have the blocks in the left column show in this order “CART” / “COMPARE” / “LAYERED NAV”

Default, the Cart block is in a separate XML file, so I moved it into the InitLayout.xml file for Categories.  The file now reads as follows:

InitLayout.xml

<reference name="right">
        <
block type="catalog/product_compare_sidebar" name="catalog.compare.sidebar">
            <
action method="setTemplate"><template>catalog/product/compare/sidebar.phtml</template></action>
        </
block>
        
         <
block type="checkout/cart_sidebar" name="cart_sidebar" before="-">
            <
action method="setTemplate"><template>checkout/cart/sidebar.phtml</template></action>
        </
block>
    </
reference>

This solved the problem.. but I’m not quite sure its how it was supposed to be done. And I’m still not sure what before="-" means.  Can anyone elaborate?

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

I Retract my statement… The above isn’t correct.  I received :

exception ‘Exception’ with message ‘Can not retrieve current category object’

After my edits. I’m assuming that since I moved blocks between XML files it’s throwing a error trying to access them?

Don’t know tho. Someone explain on this if you can.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  333
Joined:  2007-08-31
Northwest Ohio
 

before="-" means before any of the previously mentioned modules in the xml file. So that means it will be first, unless a module after it is said to be before the module that is before="-"

Make any sense?

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Yeah it does make sense… I managed to get it working by setting the module I wanted first (cart) as “before="-", like you mentioned.  The others I specified their order by how they display in the XML file.  Seems to be ok now.  This is actually… fun. -=)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top