Thứ Hai, 1 tháng 11, 2010

How to Show static block only on homepage in magento

If you are in header.phtml file then you can call $this->getIsHomepage();


But if you are not there then you must have to create instance of Mage_Page_Block_Html_Header(); then write the following code to check homepage


<?php

$ref = new Mage_Page_Block_Html_Header();

if($ref->getIsHomePage()){ ?>

<div class="homepage"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('Your_StaticBlock_Id')->toHtml();?></div>

<?php

}

?>

Không có nhận xét nào:

Đăng nhận xét