Reputation: 306
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
Reputation: 543
You can try to check the front page with this code:
if (JUri::getInstance()->toString() == JUri::base()) { ... }
Upvotes: 8