Ibnu Syuhada
Ibnu Syuhada

Reputation: 306

Check frontpage of joomla 2.5

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.

Upvotes: 2

Views: 3782

Answers (1)

Dmitrijs Rekuns
Dmitrijs Rekuns

Reputation: 543

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

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

Upvotes: 8

Related Questions