Magento check current page is Homepage
The following code is used to check if the current page is homepage.
<?php if( Mage::getSingleton('cms/page')->getIdentifier() == 'home' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' ) : ? >
The other way is to do the following way: works on 1.4.x
<?php if($this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))): echo "Homepage"; else: echo "Not in Homepage"; endif; ?>
Note: You can use “Mage::getUrl()” function where “$this” reference is not valid.
14 Comments
leaf on July 16th, 2010
221Great, it’s helpful for me!
vignesh on September 29th, 2010
243This function not working inside the top.phtml
nikhil on October 12th, 2010
249thanks budy i was finding from many time
vignesh on October 20th, 2010
250this function working in header.phtml in magento 1.3 only.. it is not work in latest magento 1.4.1
salik on November 1st, 2010
251Thanks buddy…
ecommerce web design on January 22nd, 2011
261Give more details about this blog for subscribe. Thanks for this blog.
Jonas on February 12th, 2011
265Exactly what I was looking for… there was another suggestion with using $_SERVER['REQUEST_URI']. But this didn’t work. Magento just showed nothing at all. Does anyone know why this is?
Hanan Ali on February 18th, 2011
266Thanks for script
its helpful
Praveen on February 18th, 2011
267It was really a helpful stuff. I used the same method to get the inner page and to the needed changes which is applicable to specified page. Any code updation needed this code to work in magento 1.4.1?
Golive on October 4th, 2011
412Does not work in Magento 1.5. Do you have an update on this? Would be great!!
Chetaru on November 2nd, 2011
417Thanks for sharing this information and resources its really help full for me with the help of this we can improve our magento working.
Web Design Company India
Arvind Bhardwaj on November 3rd, 2011
419Very nice trick.
Thanks:)

Welcome to my blog site. My name is Anunay Dahal. I'm currently working
Polychrome on June 28th, 2010
215Very handy thanks a lot