0

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>
  • 2
    You wrote : <blocks> < foo_bar >Foo_Bar_Block</ cwd_appratings > </blocks> But you have badly closed your node.. – Kozame Oct 20 '17 at 12:38
  • Thanks for the quick reply, I missed that closing tag while sanitizing my work-owned code before posting. In this posting, Foo is the company name, and Bar is the module name – Nick P Oct 20 '17 at 12:47
  • You didn't get any error in your log files ? – Kozame Oct 20 '17 at 12:52
  • Checked my error logs, and no logs given. On the DOM, I see <div class="app-ratings"></div> then the rest of the page renders normally as though getChildHtml isn't returning anything – Nick P Oct 20 '17 at 13:30
  • 1
    May be you need to put the node "<updates>" between <frontend><layout> and <foo_bar><file> ? – Kozame Oct 20 '17 at 13:45
1

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>
-1

Please add update tag inside layout node in you config.xml like <updates> <foo_bar> <file>foo_bar.xml</file> </foo_bar> </updates>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.