Magento Forum

XML file theming layer poorly documented
 
peach
Jr. Member
 
Total Posts:  22
Joined:  2008-01-11
 

I’ve read through the designers guide but I still can’t look at the xml files and see where all the tag attributes are referring to..
Example code from catalog.xml:

<catalog_product_view>
        <!-- 
Mage_Catalog -->
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </
reference>
        <
reference name="head">
            <
action method="addJs"><script>varien/product.js</script></action>
        </
reference>
        <
reference name="content">
            <
block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
                <
block type="catalog/product_view_super_config" name="product.info.config" as="super_config" template="catalog/product/view/super/config.phtml"/>
                <
block type="catalog/product_view_super_group" name="product.info.group" as="super_group" template="catalog/product/view/super/group.phtml"/>
                <
block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml"/>
                <
block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />
            </
block>
        </
reference>
        <
reference name="right">
            <
block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
        </
reference>

    </
catalog_product_view>

-I’m pretty sure that catalog_product_view refers to the type of page that is being viewed, and the child elements are used when it’s demanded that the catalog.xml layout is updated to the product_view layout (rather than default layout).

-the template attribute loads the contents of the block by loading the phtml file

-block type, how does this work?

-block name, whats the use of this again?

And then in other files I see a method used called thisChildHtml or something, how does that compare to whats happening to the above code?

That’s all my questions for now smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
peach
Jr. Member
 
Total Posts:  22
Joined:  2008-01-11
 

as – This is the name by which a template calls the block in which this attribute is assigned. When you see the getChildHtml(’block_name’) PHP method called from a template , you can be sure it is referring the block whose attribute ‘as’ is assigned the name ‘block_name’. (ie. The method <?=$this->getChildHtml('header')?> in the a skeleton template correlates to <block as=“header”>

This type of explanation covers the technical side of it but I think it would be helpful to add some examples of how to use it in practice. Alternatively you can just add this code to the guide;

Global $user;
 if (
$user->IQ 190{
  
print '<h1>Don't bother reading this!</h1>'; 
 }

Just kidding of course, the guide is comprehensible but it sure can be better, maybe a chart that depicts the callbacks between template files would clear up all the mist around this complex templating engine.

 
Magento Community Magento Community
Magento Community
Magento Community
 
peach
Jr. Member
 
Total Posts:  22
Joined:  2008-01-11
 

and the first example involves using main.xml, which has become obsolete.
The second as well but that one was easy to figure out nevertheless

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