1

I'm currently making my own module, but i'm having trouble with just displaying a block in the catalog product view.

I've added this line to default/layout/catalog.xml

<block type="catalog/product_view" name="product.info.rating" template="rating/rating.phtml"/>

and my template/rating/rating.phtml looks like this

<p>halp</p>

1 Answer 1

2

Add this in your your_theme_path/layout/local.xml instead.

<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
   <reference name="product.info">
       <block type="catalog/product_view" name="product.info.rating" template="rating/rating.phtml"/>
   </reference>
</catalog_product_view>
</layout>

Now call child html in theme/template/catalog/product/view.phtml

<?php echo $this->getChildHtml('product.info.rating') ?>

Another way

If you don't want to edit theme/template/catalog/product/view.phtml file then change your local.xml as follow:

<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
   <reference name="alert.urls">
       <block type="catalog/product_view" name="product.info.rating" template="rating/rating.phtml"/>
   </reference>
</catalog_product_view>
</layout>

This block will appear automatically in product view page, however it will be called along with other alert.urls

2
  • I figured it out, it was because the view.phtml was in another theme. But thanks for your help
    – leu2tm
    Sep 29, 2015 at 0:52
  • Great, you still can choose this as right answer to help others. Cheers Sep 29, 2015 at 0:55

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.