B-219 Sec-55 Noida, India
+918010221733

Check current page is homepage or not In Magento

Sometimes we want to check that current page is homepage or not through the code in Magento. In this post I am trying to solve such kind of the problem, It is very simple and you can get this from the code below:

Method 1:

<?php
if($this->getIsHomePage()) {
echo 'Hello Its Homepage!';
} else {
echo 'Its not Homepage!';
}
?>

Method 2:

<?php

$route = Mage::app()->getRequest()->getRouteName();
$pageidentifier = Mage::getSingleton('cms/page')->getIdentifier();

if($route == 'cms' && $pageidentifier == 'home') {
echo 'Hello Its Homepage!';
} else {
echo 'Its not Homepage!';
}

?>

(Visited 63 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.