2012-04-12 53 views
0

在Magento產品template/catalog/product/view.phtmlMagento的產品視圖文件

getchildhtml('container1','',true, true); 
getchildhtml('container2','',true,true); 

通過這個我得到的定製選項下拉。

什麼是container1container2以及它們從哪裏渲染?

回答

0

getChildHTML()功能包含在http://svn.magentocommerce.com/source/branches/1.2/app/code/core/Mage/Core/Block/Abstract.php

從看源代碼,它正在尋找以前指定爲「container1」或「container2的」東西。看起來這是通過包含在同一文件中的setChild()函數設置的。

現在只要在verbage「container1」和「container2的」從何而來,我認爲它來自佈局,在該位源的看出:http://svn.magentocommerce.com/source/branches/1.4/app/design/frontend/default/modern/layout/catalog.xml

<block type="core/template_facade" name="product.info.container1" as="container1"> 
    <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action> 
    <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
    <action method="append"><block>product.info.options.wrapper</block></action> 
    <action method="append"><block>product.info.options.wrapper.bottom</block></action> 
</block> 
+0

嘿cillosis thxn budy – chandanv 2012-04-12 12:50:36

0

看目錄。設計>前端>基礎>默認>佈局> catalog.xml中的xml文件,您將看到container1和container2的定義。

<block type="core/template_facade" name="product.info.container1" as="container1"> 
        <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action> 
        <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
        <action method="append"><block>product.info.options.wrapper</block></action> 
        <action method="append"><block>product.info.options.wrapper.bottom</block></action> 
       </block> 
       <block type="core/template_facade" name="product.info.container2" as="container2"> 
        <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action> 
        <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action> 
        <action method="append"><block>product.info.options.wrapper</block></action> 
        <action method="append"><block>product.info.options.wrapper.bottom</block></action> 
       </block> 

方塊型「的核心/ template_facade」是類Mage_Core_Block_Template_Facade

您也可以打開在管理模板提示。看看這個信息如何做到這一點:How to trace where Magento is calling templates from?

+0

哇哇的人tuong le tats g8你保持聯繫,因爲我是一個初學者在magento :-)真的hlpd我通過達提示 – chandanv 2012-04-12 12:51:45