I've made code of most viewed products which I'm trying to call under custom header. This is what I've done so far.

Posted the block code under cms block by name 'most_viewed'.

{{block type="mostviewed/list" name="home.mostviewed.list" alias="product_homepage" template="catalog/product/mostviewed.phtml"}}

and then I've posted the below code under my custom header but it's showing block. Suggest me some good idea to do.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('most_viewed')->toHtml(); ?>
  • in which pages custom header has been called?
    – Amit Bera
    Apr 9, 2015 at 18:14
  • Only on home page Apr 9, 2015 at 18:17
  • where you call {{block type="mostviewed/list" name="home.mostviewed.list" alias="product_homepage" template="catalog/product/mostviewed.phtml"}} code at admin
    – Amit Bera
    Apr 9, 2015 at 18:18
  • Already said above that I've called that under cms-block Apr 9, 2015 at 18:21
  • Without {{block type="mostviewed/list" name="home.mostviewed.list" alias="product_homepage" template="catalog/product/mostviewed.phtml"}} code, Have you add any thing else in ] cms blocks
    – Amit Bera
    Apr 9, 2015 at 18:24

1 Answer 1


According to discussion with you.you need to do this by using layout xml

Home handler: cms_index_index is unique for homepage.

Suppose that the name of custom header is customheader

then you can define the most_viewed by

<reference name="customheader">
<block type="mostviewed/list" name="home.mostviewed.list" as="product_homepage" template="catalog/product/mostviewed.phtml" />

Then you need call this block by using getChildHtml(BlockNameATXmlCOde)

<?php echo $this->getChildHtml('product_homepage');?>

Please put this code at cms.xml or local.xml at app/design/frontend/YOUR_PAcakage/YOUR_TEMPLATE/layout/

If you using layout code then no need to cms block

Hi you need to change reference name custom header

<reference name="header"> <block type="page/header" name="customerheader"> <action method="setTemplate"><template>cms/home.phtml</template></action> </block></reference>

Then accordingly you need to change most view block reference block name

<reference name="customerheader"> <!-- here parentblock name which is define at above xml -->
<block type="mostviewed/list" name="home.mostviewed.list" as="product_homepage" template="catalog/product/mostviewed.phtml" />
  • not working though Apr 9, 2015 at 18:49
  • please tell me ?name of custom header at layout xml code ? Just block type="mostviewed/list" name="home.mostviewed.list" as="product_homepage" template="catalog/product/mostviewed.phtml" name is name="home.mostviewed.list" and aliase name is product_homepage
    – Amit Bera
    Apr 9, 2015 at 18:51
  • Well I've simply put the <reference name="header"> <block type="page/header" name="header"> <action method="setTemplate"><template>cms/home.phtml</template></action> </block> in Home LAYOUT DESIGN </reference> Apr 9, 2015 at 18:53
  • just change reference name="customheader" to reference name="header".Also i have using alias name in childblock call
    – Amit Bera
    Apr 9, 2015 at 18:55
  • Well I do have changed that to header and posted and also I've called with alias name but still not working. Apr 9, 2015 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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