Joomla is a excellent content management software with lots of options to customize your website with themes and plugins. Sometime when you are designing websites using Joomla, you might want to implement a particular function or image or content only on the home page and not in the inside pages. The home page in Joomla is called Front page and you can easily check if the page is front page using the code below.
To check if the current page is Front/Home page or not use the code below;
<?php if(JRequest::getVar(‘view’) == “frontpage” ) : ?>
<!– your home page code –>
<?php else : ?>
<!– your code –>
<?php endif; ?>
Apart from this, you can also use the default menu option to check the home page. If the menu is activated, the default item for menu would be home page.
<?php $menu = &JSite::getMenu();
if (JRequest::getInt(‘Itemid’) == $menu->getDefault()) : ?>
<!– your home page code –>
<?php else : ?>
<!– your code –>
<?php endif; ?>
You can use either one of the code to see if the user is viewing the home page or not. You can add these code to the template HTML file to display code based on the page.
Gosh, I’ve been looking about this specific topic for about an hour, glad i found it in your website!
Not work. The frontpage is same with menu blog category…..
here $menu->getDefault() is not int, but an object and will show error