2012-06-01 100 views
1

在我的magento模板中,我在主頁中使用了下面的代碼「getChildHtml('content')」。在哪裏使用模板文件中的getChildHtml()加載內容?Magento模板設計

回答

2

您可以在page.xml中找到您的頁面全局結構。例如,如果你可以使用3個colums

<default translate="label" module="page"> 
    <label>All Pages</label> 
    <block type="page/html" name="root" output="toHtml" template="page/3columns.phtml"> 
.... 

然後,在你的設計主題的模板頁/ 3columns.phtml你可以看到這PHTML進入它,你可以看到這一點:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>"> 
<head> 
<?php echo $this->getChildHtml('head') ?> 
</head> 
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>> 
<?php echo $this->getChildHtml('after_body_start') ?> 
<div class="wrapper"> 
    <?php echo $this->getChildHtml('global_notices') ?> 
    <div class="page"> 
     <?php echo $this->getChildHtml('header') ?> 
     <div class="main-container col3-layout"> 
      <div class="main"> 
       <?php echo $this->getChildHtml('breadcrumbs') ?> 
       <div class="col-wrapper"> 
        <div class="col-main"> 
         <?php echo $this->getChildHtml('global_messages') ?> 
         <?php echo $this->getChildHtml('content') ?> 
        </div> 
        <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div> 
       </div> 
       <div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div> 
      </div> 
     </div> 
     <?php echo $this->getChildHtml('footer') ?> 
     <?php echo $this->getChildHtml('before_body_end') ?> 
    </div> 
</div> 
<?php echo $this->getAbsoluteFooter() ?> 
</body> 
</html> 

與getChildHtml('content')?>。 這是解決你的問題嗎?

+0

是的我的問題已經在您的代碼幫助下得到修復。謝謝 – Maniprakash

+1

我還有一個問題。可以在magento集合加載中解釋Mage :: getModel()和Mage :: getSingleton()之間的區別。 – Maniprakash

+0

這是一個設計模板,在Magento中你有很多這個。 Whit Mage :: getSingleton()確保ob對象的實例是唯一的,例如:Mage :: getSingleton('customer/session')。你想要原始對象,實際檢索活動會話,如果你在實例中調用一個新對象,則可以使用Mage :: getModel()。但是你可以提出一個新問題。我準備好回答:P – davidselo