Friday, 31 August 2012

Magento important Code Snippet

Only echo on your ip:


if($_SERVER['REMOTE_ADDR']=='yourip')
{
//do your echo stuff
}


Detecting Home page:

$routeName = Mage::app()->getRequest()->getRouteName();
$identifier = Mage::getSingleton('cms/page')->getIdentifier();
if($routeName == 'cms' && $identifier == 'home')
{
//do your stuff only needed in home page.
}


Adding CMS Static Page in any pthml page

echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer_banner')->toHTML();

No comments :

Post a Comment