The method of getChildHtml

The php method getChildHtml(’right’) does not refer in any way to right.phtml. “right” is simply an identifier in order for templates and the layout file to interact with each other in order to structure and bring content to the page. Remember, changing the layouts of a page in Magento means no longer relying on manual XHTML inclusion in one large structural block template such as col_right.phtml. Think of it this way:

There are now three parts to modifying page layout. One is the structural templates, two, content templates, and three is what Magento calls “layouts”.
Structure templates are templates that simply creates the structural layout of a page - such template exists only to designate real estate for content inclusion. A sample structural template would look something like the following:

< div  class= "header" > <? = $this -> getChildHtml ( 'header' ) ?> </ div >
<
div  class= "col-left" > <? = $this -> getChildHtml ( 'left' ) ?> </ div >
<
div  class= "col-main" > <? = $this -> getChildHtml ( 'content' ) ?> </ div >
<
div  class= "col-right" > <? = $this -> getChildHtml ( 'right' ) ?> </ div >
<
div  class= "footer" > <? = $this -> getChildHtml ( 'footer' ) ?> </ div >

You can see how the XHTML used in a skeleton template is only there to build structural.

A layout arranges the content blocks such as product tags, category listing, mini cart, mini wishlist..etc, then delivers it to the structural block to be parsed in the assigned order.
All this in human language is basically “Grab all the mini cart, grab the compare products, grab the poll and the grab the newsletter sign up box, and put all this inside the <div class="col-right">." The one that orders this whole operation, is the layout . Each of the mini-cart, compare products..etc are the content blocks. The <div class="col-right"></div> is the structural block.

The layout only knows where to include all the content blocks via the getChildHtml() method used in the structural template. Using the assigned identifier called “right” as in getChildHtml(’right’), the layout knows where to put all the content blocks it gathered - inside the <div class="col-right"></div>

For each design theme, you have a default layout, and the subsequent layout updates. The default, is what sets the default layout for the whole store, and the layout updates is the layout that modifies(updates) the default layout per store page. So if the default layout says, use 3 columns, but you want your product info page to use 2 columns only, you’d update the <catalog_product_view> “handle” inside main.xml to reflect this. Main.xml is pretty well commented - read through it carefully with open eyes and you’ll see what’s happening there. Also the Magento team is here to assist you with any questions - 24 hours a day 7 days a week - (we are born with each finger stuck to a keyboard...and we have mutating tentacles to accommodate all the other keys we can’t cover with the 10 fingers)

O.K.!! we got the concept over with. Now let’s get our hands dirty, stinky, muddy, cracking, invigorated, satisfied...happy.
Comment out the following codes from main.xml

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

 

< reference name = "right" >
           <
block type = "newsletter/subscribe"  name = "right.newsletter"  template = "newsletter/subscribe.phtml" />
        </
reference >
< reference name = "right" >
            <
block type = "poll/activePoll"  name = "right.poll" >
                <
action method = "setPollTemplate" >< template > poll / active . phtml </ template >< type > poll </ type ></ action >
                <
action method = "setPollTemplate" >< template > poll / result . phtml </ template >< type > results </ type ></ action >
            </
block >
        </
reference >

Now reload the page. That’s all-

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值