2013-07-09 22 views
0

我的代碼:如何Magento顯示身體標記的外塊

<reference name="before_body_end"> 
    <block type="test/test" template="test/test.phtml" name="test-test" /> 
</reference> 

當我改變

<reference name="after_body_end"> 
    <block type="test/test" template="test/test.phtml" name="test-test" /> 
</reference> 

那麼它是不工作。請幫助

回答

1

它不起作用,因爲您正在引用...呃...沒有。名稱爲after_body_end的塊不存在。
我將解釋如何添加它,但首先我想說清楚,我不贊成在body標籤外添加html。這可能會導致某些瀏覽器出現問題。
首先,您需要創建名稱爲after_body_end的塊。
對於這個編輯文件的應用程序/設計/前端/ {接口}/{}主題和/layout/page.xml查找此:

<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label"> 
    <label>Page Bottom</label> 
</block> 

右鍵根據該添加以下。

<block type="core/text_list" name="after_body_end" as="after_body_end" translate="label"> 
    <label>Page Unde the body tag</label> 
</block> 

現在您的塊已存在。您只需將其添加到您的頁面即可。對於此編輯下列文件中的所有位於app/design/frontend/{interface}/{theme}/template/page/

  • 1column.phtml
  • 2columns-left.phtml
  • 2columns-right.phtml
  • 3columns.phtml
  • empty.phtml
  • popup.phtml
  • print.phtml

對於所有這些文件下添加</body>線這樣的:

<?php echo $this->getChildHtml('after_body_end') ?> 

清除緩存和享受。