Hide content or modules from frontpage in Joomla

Often we come to conditions where we do not want to display modules or content in the front page. One example of this is, we do not display breadcrumb (pathway) in the front page of a Joomla website. So, lets see how we can achieve this:

Please note that the simplest way to hide modules from front page is to click on the required module from Joomla administration and under menu assignment, you can select all other menu items except home menu. This will display the module on all pages except front page. However, this method does not work for some of our specific requirements. Also, to hide content from front page, you need to follow the method described below.

To hide content or modules from front page, we need to modify index.php file of the default template. So, open index.php file of your default template, which is inside templates/[default template folder]/.

How to hide content from front page?

To hide content from front page, you need to add following code where you display content in your template:

$menu = &JSite::getMenu();
if ($menu->getActive() != $menu->getDefault()) {
    <jdoc:include type="component" />
<?php } ?>

How to hide module from front page?

To hide module from front page, you need to add the module position in the place of component, such as:

$menu = &JSite::getMenu();
if ($menu->getActive() != $menu->getDefault()) {
    if($this->countModules('breadcrumb')) : ?>
                <div id="breadcrumb">
                    <jdoc:include type="modules" name="breadcrumb" />
                <?php endif; 

} ?>

Here, the module position breadcrumb is displayed in other pages except front page. We have also checked if there is any module published in the breadcrumb position or not.

Hiding modules for specific pages in a component displayed in front page

Sometimes the above described methods may not be sufficient to achieve what we wanted. One of the cases that I have faced is when I was developing a directory site in Joomla. I have used SOBI2 extensions and in the front page, the SOBI2 categories were displayed. And the requirement is, do not display the breadcrumb in the front page (the category page) while in other pages (sub-category pages, item details page etc.) of SOBI2 we need it. Now, non of the methods described above worked for me, because the Itemid that the menu takes is same for all pages as it was for the home page.

So, I slightly modified the above if condition for not just checking the default menu item as well as the URL return value by get method. The example is as:


You can leave a response, or trackback from your own site.

One Response to “Hide content or modules from frontpage in Joomla”

Leave a Reply


Powered by WordPress | Buy cheap cell phones at iFreeCellPhones.com | Thanks to iCellPhonePlans.com, Facebook Games and Free Ads