Difference between revisions of "How to determine if the user is viewing the front page"
From Joomla! Documentation
m (Added category) |
|||
Line 17: | Line 17: | ||
</source> | </source> | ||
This works by checking to see if the current active menu item is the default one. | This works by checking to see if the current active menu item is the default one. | ||
− | <noinclude>[[Category:Development]]</noinclude> | + | <noinclude> |
+ | [[Category:Development]] | ||
+ | [[Category:Tutorials]] | ||
+ | </noinclude> |
Revision as of 15:13, 14 January 2011
In Joomla! 1.0.x it was possible to determine if the user was viewing the front page by using code like this:
<?php
if ($option == 'com_frontpage' || $option == '') {
echo 'This is the front page';
}
?>
But in Joomla! 1.5.x the com_frontpage component is no longer present. This is how to achieve the same result in Joomla! 1.5.x
<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}
?>
This works by checking to see if the current active menu item is the default one.