Joomla plugin and templating: how to know if you are in the frontpage
There are many situations in which a joomla developer needs to know if the code is being shown / executed in the main page. This is, the “context” in which the code is executed. For instance, if you want to use a different template for the frontpage and another for other visualizations (custom frontpage). Or if you only want a plugin to be shown if the page is not frontpage.
How is this done?
Joomla 1.0.*
<?php if($_REQUEST['option']=="com_frontpage" || !isset($_REQUEST['option'])){?> Have the HTML code for the homepage layout <? } else{?> Have HTML code for the rest of the pages <?php } ?>
Joomla 1.5.*
<?php if($_REQUEST['view']=="frontpage") {?> Have the HTML code for the homepage layout <? } else{?> Have HTML code for the rest of the pages <?php } ?>
Related posts: