For Joomla 2.5 and 3.x use the following code for a site with one language:
<?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is homepage'; } ?>
For multilingual sites, the definition of the main page (main page) depends on the currently selected language, so you will need to use something like the following:
<?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault( 'en-GB' )) { echo 'This is English homepage'; } elseif ($menu->getActive() == $menu->getDefault( 'it-IT' )) { echo 'This is Italian homepage'; } ?>
For multilingual sites, you can also use the following code:
<?php $app = JFactory::getApplication(); $menu = $app->getMenu(); $lang = JFactory::getLanguage(); if ($menu->getActive() == $menu->getDefault($lang->getTag())) { echo 'This is homepage'; } else { echo 'This is not homepage'; } ?>
Hope this helps!
Reza baradaran
source share