How to determine if the user is viewing the Joomla front page

If you're using Joomla! 1.0 then you'll only need to verify the current component with the following command:

PHP:
  1. if ($option == 'com_frontpage' || $option == '') {
  2.   echo 'This is the front page';
  3. }

This task for Joomla! 1.5 could be easily confirmed by the following command:

PHP:
  1. if ( JRequest::getVar('view') === 'frontpage' ) {
  2.   echo 'This is the front page';
  3. }

Just in case the above command doesn't work then the issue could be a little more complicated and need to check if the current active menu item is the default one.  I saw this issue in some 1.5 early versions.

PHP:
  1. $menu =& JSite::getMenu();
  2. if ($menu->getActive() == $menu->getDefault()) {
  3.   echo 'This is the front page';
  4. }

Post a Comment

Your email is never shared. Required fields are marked *

*
*