0

I must to make a modify only in home page. How i can to understand if i am in home page? I have tried with

$currentUrl = $this->helper('core/url')->getCurrentUrl();

but my url is:

http://www.miosito.com/it/?___from_store=en

The best solution are get urlkey but how to do? or to eliminate ?___from_store=en

1 Answer 1

0

You can use below code to check homepage

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

if($routeName == 'cms' && $identifier == 'home') {
    echo 'This is Magento Homepage.';
} else {
    echo 'This is not a Magento Homepage.';
}

From your comment i suggest you use above code $identifier == 'home' change cms page 'home' identifier with your homepage identifier.

also alternative way to check is this home page

if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()) {
    echo 'This is Magento Homepage.';
} else {
    echo 'This is not a Magento Homepage.';
}
3
  • I have insert this: if ($this->getIsHomePage()) { and work well if my home is www.miosito.com/it/ but when i change language the url become miosito.com/it/?___from_store=en I need to remove ?___from_store=en Commented Mar 3, 2016 at 8:54
  • but it is only working in header.phtml because getIsHomePage() function of Mage_Page_Block_Html_Header block. Commented Mar 3, 2016 at 9:00
  • 1
    i have changed the file languages.phtml. there is a string: $_lang->getCurrentUrl() modified $_lang->getCurrentUrl(false) work for me! Commented Mar 3, 2016 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.