LearnWebDesignOnline.com is proudly hosted by Hostmonster.com

Sometimes in Joomla code, you want to determine what page type is being displayed. This is also known as the "view". You can use getVar method of the JRequest object as in ...
<?php
echo JRequest::getVar('view');
?>
To test this out, put this code in near the bottom of the index.php of your template (just above the closing body tag) and you should see it return "frontpage", "section", "category", or "article" depending on the page type.
Note: The index.php template file that I am referring to is typically found in <your joomla install dir>/templates/<your template dir>/index.php.
As an example, suppose you want to display something different on the home page than in your other internal pages, then you can write this PHP code in your index.php template file.
<?php
if ( JRequest::getVar('view') == 'frontpage' ) {
?>
<!-- display your home page HTML here -->
<?php
} else {
?>
<!-- display your internal page HTML here -->
<?php } ?>
The getVar('view') method can also tell you what section the article is categorized in. See article "Find Section Name" for details.
If you want to select pages based on their menu alias, you can try the following code...
$theMenu = JSite::getMenu();
$theActiveMenu = $theMenu->getActive();
if ( strpos($theActiveMenu->alias, 'wii') !== false ) {
/* you are on a page where menu alias has "wii" in it */
}
