Determine if the user is viewing Home page in Joomla

// Joomla 1.5 <?php $menu = & JSite::getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is the front page'; } ?> // Joomla 2.5 <?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is the front page'; } ?> //For multi-lingual sites the front page is dependent on the currently selected language, so you will need to use code like this: <?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault( 'en-GB' )) { echo 'This is the front page'; } elseif ($menu->getActive() == $menu->getDefault( 'fr-FR' )) { echo 'Accueil'; } ?> //For multi-lingual sites, it could also be necessary to display a specific code/html for all Default Home pages. <?php $app = JFactory::getApplication(); $menu = $app->getMenu(); $lang = JFactory::getLanguage(); if ($menu->getActive() == $menu->getDefault($lang->getTag())) { echo 'This is the front page'; } else { echo 'Accueil'; } ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.