Check frontpage of joomla 2.5

joomla, php

Solution

You can try to check the front page with this code:

if (JUri::getInstance()->toString() == JUri::base()) { ... }

Problem

I was read the instruction from joomla, that if I want to check the current page is front page like below ``` <?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { echo 'This is the front page'; } ?> ``` But, when I practised this instruction. The text "This is the front page" is always showed on all pages. How this can happen on my joomla.

Original source