0

I saw this answer Static block on home page in Magento but cant make it work.

Im just trying to add a custom block in my home page. These are the things I've done:

1- Add this to my layout file.

<cms_index_index>
    <reference name="content">
       <block type="aitshopassist/assistant" name="aitshopassist_assistant" template="aitshopassist/assistant.phtml">
           <action method="setBlockId"><block_id>shop_assistant_block</block_id>
           </action>
       </block>
     </reference>
</cms_index_index>

2- Added this to the 2columns-right.phtml file:

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

Also, the block is shown correctly in catalog_category_view.

What am I missing?

<catalog_category_view>
    <reference name="content">
        <block type="aitshopassist/assistant" name="aitshopassist_assistant" template="aitshopassist/assistant.phtml" before="category.products" />
    </reference>
</catalog_category_view>

I tried this in the cms_index_index but didnt work..

Community
  • 1
  • 1
davibq
  • 1,089
  • 11
  • 31
  • The `getChildHtml` method is going to look at the `name` value, which is `aitshopassist_assistant`, not `shop_assistant_block`. How is this showing correctly in `catalog_category_view`? Can you paste the layout update that you used to pop it in there? – kalenjordan Aug 06 '12 at 23:07
  • I edit the question, there is the catalog code for the layout. Thank you – davibq Aug 08 '12 at 15:12

2 Answers2

2
 <block type="cms/block" name="aitshopassist_assistant" before="-">
        <action method="setBlockId"><block_id>shop_assistant_block</block_id></action>
  </block>

set it in xml file for calling block

drsndodiya
  • 1,685
  • 1
  • 17
  • 36
0

Just echo following code in your home phtml file:

$this->getLayout() ->getBlockSingleton('aitshopassist/assistant')->setTemplate('aitshopassist/assistant.phtml')->toHtml();
kleopatra
  • 51,061
  • 28
  • 99
  • 211
Umer Ahmed Khan
  • 246
  • 2
  • 4