More than 1000+ satisfied clients and counting, since 2010

Blog

Joomla HomePage – How to Determine the Homepage in Joomla?

Test whether you are viewing the Joomla homepage or not

Joomla Homepage Each Joomla website has a home page from which all other pages are accessible. This unique page which is interlinked with all other pages after a specific number of navigation is called Joomla home page. But practically, it is difficult to identify the homepage in Joomla.

Determine the Joomla Homepage

This post covers how to determine whether a user is viewing the Joomla homepage or not. Follow the codes given below as per your Joomla version.

  • Test Joomla Homepage in 1.5

<?php

$menu = & JSite::getMenu();

if ($menu->getActive() == $menu->getDefault()) {

echo ‘This is the front page’;   } ?>

  • Test Joomla Homepage in 1.6

if(JRequest::getVar(‘view’) == “featured” )

{    //You are in!   }

else {   //You are out!   }

  • Test Joomla Homepage in 1.7

if(JRequest::getVar(‘view’) == “featured” )

{   //You are in!   }

else {   //You are out!   }

  • Test Joomla Homepage in 2.5

<?php

$app = JFactory::getApplication();

$menu = $app->getMenu();

if ($menu->getActive() == $menu->getDefault()) {

echo ‘This is the front page’;  }  ?>

  • Test Joomla Homepage in Multi-lingual Sites

<?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’;   }   ?>

Written by

The author didnt add any Information to his profile yet