Why doesn't custom block appear on product page
-
14-12-2020 - |
Вопрос
Good afternoon, I'm suspecting this is an easy oversight.. I've been working today on putting a custom block onto a product page. But, nothing from my template is showing up. Take a look at my code below:
my config.xml:
<config>
<modules>
<Foo_Bar>
<version>1.0</version>
</Foo_Bar>
</modules>
<global>
<models>
<foo_bar>
<class>Foo_Bar_Model</class>
<resourceModel>bar_resource</resourceModel>
</foo_bar>
<bar_resource>
<class>CWD_Appratings_Model_Resource</class>
<entities>
<rating>bar_rating</rating>
</entities>
</bar_resource>
</models>
<blocks>
<foo_bar>Foo_Bar_Block</foo_bar>
</blocks>
<helpers>
<foo_bar>
<class>Foo_Bar_Helper</class>
</foo_bar>
</helpers>
</global>
<frontend>
<layout>
<foo_bar>
<file>foo_bar.xml</file>
</foo_bar>
</layout>
</frontend>
</config>
My theme/default/layout/foo_bar.xml
<layout version="0.1.0">
<catalog_product_view>
<reference name="product.info">
<block type="catalog/product_view" name="bar_widget" as="bar_widget" template="foo/bar/widget.phtml" />
</reference>
</catalog_product_view>
</layout>
and my code in theme/template/catalog/product/view.phtml
<div class="app-ratings">
<?php echo $this->getChildHtml('bar_widget'); ?>
</div>
Решение
You forgot a node in your config file :
<frontend>
<layout>
<updates> <-- this one
<foo_bar>
<file>foo_bar.xml</file>
</foo_bar>
</updates>
</layout>
</frontend>
Другие советы
Please add update tag inside layout node in you config.xml like <updates> <foo_bar> <file>foo_bar.xml</file> </foo_bar> </updates>
Не связан с magento.stackexchange