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

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.';
}
  • 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 – Alessandro Gnola Mar 3 '16 at 8:54
  • but it is only working in header.phtml because getIsHomePage() function of Mage_Page_Block_Html_Header block. – Prashant Valanda Mar 3 '16 at 9:00
  • 1
    i have changed the file languages.phtml. there is a string: $_lang->getCurrentUrl() modified $_lang->getCurrentUrl(false) work for me! – Alessandro Gnola Mar 3 '16 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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