How to determine if the user is viewing the front page

In Joomla! 1.0.x it was possible to determine if the user was viewing the front page by using code like this:
Determine if user is viewing the front page in Joomla! 1.0.x
<?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
Determine if user is viewing the front page 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.

Nhận xét

Bài đăng phổ biến từ blog này

Ký tự viết tắt trong chat & email

dung lượng RAM lớn nhất mà HĐH cấu trúc 32-bit nhận được

Ubuntu LAMP Server