0
votes

I am new with working with Magento and I am trying to add a 'Recently Viewed' block to the bottom of the Product View page. I created a catalog.xml layout file here ->

/app/design/frontend/default/<theme_name>/layout/catalog.xml

I then edited this file to add the 'Recently Viewed Products' block as shown here ->

<reference name="content">
     <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
          <block type="catalog/product_view_media" name="product.info.media" as="media"  template="catalog/product/view/media.phtml"/>

     <reference name="content">
         <block type="reports/product_viewed" name="reports.product_viewed" as="product_viewed" template="reports/product_viewed.phtml"/>
     </reference>
 ...

NB - I also tried it without the <reference name="content"></reference> wrappers with the same result.

In the view.phtml template I added the following:-

<?php echo $this->getChildHTML('product_viewed'); ?>

However nothing is displayed and with the debug template hints switched on there is no reference to the newly added block template..

Can anyone see where I have gone wrong? Many thanks Rich

1

1 Answers

1
votes

I'm not sure but if the snippet is exactly how you put it in the local.xml then you have wrong syntax. You have the reference name content twice. Try to place the

<reference name="content">
     <block type="reports/product_viewed" name="reports.product_viewed" as="product_viewed" template="reports/product_viewed.phtml"/>
 </reference>

outside of:

<reference name="content">
     <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
          <block type="catalog/product_view_media" name="product.info.media" as="media"  template="catalog/product/view/media.phtml"/>

or remove the reference tag from the products view block. In addition to that i would recomend to make your layout changes in an local.xml file. Create a new file in your theme/layout folder and make the changes there. It's more magento like working and the local.xml changes will allways override the normal xml structure.

Hope that helps!