问题
Hi i am developing a simple extension in which
i need to insert a new block on product page through xml file. Below is the xml file of my module
<layout version="0.1.0">
<total_index_index>
<reference name="root">
<action method="setTemplate"><template>page/2columns right.phtml</template></action>
</reference>
<reference name="content">
<block type="total/prototal" name="total_prototal" template="total.phtml" />
</reference>
</total_index_index>
</layout>
In this, layout is working on module index action and the content of total.phtml file is visible. I need to insert the content of total.phtml on product page.
So please suggest me how can i inset this on product page through xml.
Thanks
回答1:
try this:
<catalog_product_view>
<reference name="alert.urls">
<block type="total/prototal" name="total_prototal" template="total.phtml" />
</reference>
</catalog_product_view>
make sure this line must be exist in view.phtml file:
<?php echo $this->getChildHtml('alert_urls') ?>
Hope this helps!
回答2:
I assume you have file and folder in your design like this
/template/total/prototal.phtml
In your local.xml you can add like below
<catalog_product_view>
<reference name="product.info">
<block type="core/template" name="total_prototal" template="total/prototal.phtml" after="product.info.addtocart"/>
</reference>
</catalog_product_view>
Now in your catalog/product/view.phtml
, call your custom block
Before
<?php echo $this->getChildHtml('addtocart') ?>
Add
<?php echo $this->getChildHtml('total_prototal') ?>
来源:https://stackoverflow.com/questions/23757335/add-some-block-to-product-view-page-through-module-xml-file-magento