我想在每個產品頁面的價格下添加一個靜態框,但我不想覆蓋現有的模板文件(例如catalog/product/view.phtml)來渲染它的子塊。如何在不編輯現有模板的情況下將塊元素添加到magento中的產品視圖?
我試圖經由前端/鹼/默認/佈局添加一個塊元件/那個local.xml
<layout version="0.1.0">
<default>
<reference name="product.info">
<block type="telllowerpricelink/linkbox" name="telllowerpricelink.linkbox" template="telllowerpricelink/link.phtml" before="product.description" output="toHtml" />
</reference>
</default>
</layout>
然後我建立一個殘留的模塊:
應用程序/代碼/本地/ MyPackage的/ TellLowerPriceLink /砌塊/LinkBox.php
<?php
class MyPackage_TellLowerPriceLink_Block_Link extends Mage_Core_Block_Template
{
}
?>
應用程序/代碼/本地/ MyPackage的/ TellLowerPriceLink的/ etc/config.xml中
<?xml version="1.0"?>
<config>
<modules>
<MyPackage_TellLowerPriceLink>
<version>0.1.0</version>
</MyPackage_TellLowerPriceLink>
</modules>
<global>
<blocks>
<mypackage_telllowerpricelink>
<class>MyPackage_TellLowerPriceLink_Block</class>
</mypackage_telllowerpricelink>
</blocks>
</global>
</config>
而且我templatefile:
設計/前端/基/默認/模板/ telllowerpricelink/link.phtml
<?php
echo 'Hello world!';
?>
所以我的問題是:
1.主要問題:是否有可能加入HTML輸出(順便說一句:我沒有看到它)在父塊元素的末尾沒有編輯它的模板(一個renderChildHtml)? 2.是否有可能將我的模板文件存儲在此文件夾中,還是讓我將孔默認主題文件夾複製到自己的主題中?
非常感謝,我用Google搜索了很多,但沒有找到滿意的答案。
非常感謝。我期望這樣的事情。第一個問題的解決方法是我不會使用的。我不喜歡純JavaScript的解決方法。但是,謝謝你。第二個問題的解決方案是可以接受的。謝謝! – noeden
如果這回答你的問題,你應該接受它作爲正確的答案。 –
我正在路上。這是我的第一個評論,我無意中添加了它。 – noeden