2012-06-06 102 views
1

我有一個小的自定義模塊應該顯示在所有的產品頁面,但它不。它僅在設置其對「內容」的引用時才顯示,但我希望它在已存在的產品視圖div中顯示,因此將其顯示在「product.info」參考中。Magento:自定義模塊佈局覆蓋不起作用

這裏是我的代碼:

應用程序/設計/前端/默認/公司/佈局/公司/ socialbuttons.xml

<?xml version="1.0"?> 
<layout> 
    <catalog_product_view> 
    <reference name="product.info"> 
    <block type="core/template" name="company_socialbuttons" template="company/socialbuttons.phtml" /> 
</reference> 
    </catalog_product_view> 
</layout> 

我已經花了幾個小時發現錯誤,沒有成功和如果我很快就找不到解決方案,我會以醜陋的方式做到這一點(在父級phtml中調用phtml)。我究竟做錯了什麼?

回答

1

product.info手柄catalog/product_view塊的一個實例,並contentcore/text_list塊的一個實例。後一個塊將呈現每個子塊,即使模板中沒有調用getChildHtml()方法。
所以,如果你想添加塊到product.info,你應該在模板中調用getChildHtml()方法。
或者,你可以嘗試在product.info塊的其他的塊的參考:alert.urlsproduct.info.extrahint

+0

大,引用alert.urls(或product.info.extrahint)當模塊現在顯示。還有一個問題:有沒有辦法通過local.xml來改變alert.urls塊的位置,而無需在view.phtml中移動getChildHtml('alert_urls')調用? – Socrates

+1

@Socrates - 爲了避免使用getChildHtml調用,您爲什麼要將alert.urls塊用於完全不同的(社交媒體按鈕)。你不覺得代碼寫得好嗎? –

+0

@Socrates不幸的是,使用local.xml移動alert_urls塊是不可能的。 –

1

如果直接引用product.info塊,那麼你將在你的產品視圖模板來使用,直到最底層()的調用:

echo $this->getChildHtml('company_socialbuttons');