1

In magento I want to show a static block in homepage only.

I tried the solution mentioned in this question but it didn't work.

I added this code, in page.xml file, and it started giving error, so i cut it from their and put it in local.xml file:

<cms_index_index>
  <reference name="content">
    <block type="cms/block" name="home-page-block">
      <action method="setBlockId"><block_id>home-page-block</block_id></action>
    </block>
  </reference>
<cms_index_index>

It didn't give error, but still doesn't show static block. I even entered this in 2columns-right.phtml file, though i think it wasn't required.

<?php echo $this->getChildHtml('home-page-block') ?>

But it still didn't work. Can someone point out what am i missing?

Community
  • 1
  • 1
anwartheravian
  • 1,071
  • 2
  • 11
  • 30

2 Answers2

0

Assuming you already did all the clear-cache, disable-cache standard procedure, I think the handle is supposed to be cms_index_defaultindex instead of cms_index_index.

Secondly, you're right about the getChildHtml() bit not really necessary since you're already at <reference name="content" />.

Seth Malaki
  • 4,436
  • 23
  • 48
0
one of the easiest thing to do is
<?php
$homePageUrl = Mage::getBaseUrl(); //this gets you your domain name sort of
$currentUrl = $this->helper('core/url')->getCurrentUrl(); // this gets the current url

//you can now do your conditional stuff in here
if($currentUrl == $homePageUrl) : ?>

//then display your block by calling the block 
    <div style="margin: 0 auto; width: 100%; max-width: 1180px;">
        <?php echo $this->getLayout()
            ->createBlock('cms/block')
            ->setBlockId('seo-homepage')
            ->toHtml();
        ?>
    </div>
<?php endif; ?>