Show modules on all pages except front page

(16 votes, average 4.38 out of 5)

It’s very common to want to put modules on all pages except the front page. This recipe allows you to target the front page (or any given page) and either exclude a module from that page or include it on that page.

With JomGenius

This technique is available from MetaMod 2.4 onwards.

This assumes that you are using the standard “frontpage” component as the first menu item on your main menu. If you have changed to a different component for the first page on your site, then use the MetaMod Advanced Debug mode to find the right combination of $Itemid, $option and $view to identify the page and therefore not show the module on it.

Place module on all pages except the front page:

if ( $core_genius->check("pagetype not = frontpage" ) ) return XXX;

Place module only on the front page:

if ( $core_genius->check( "pagetype = frontpage" ) ) return XXX;

There’s also an official Joomla way to identify the front page, by comparing the “active” menu to the “default” menu (i.e. one chosen for the front page). However this does not work in all cases (e.g. sometimes it activates when a form is “posted” to index.php), so the rules above are recommended.

Place module only on the front page:

$menu =& JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) return XXX;

Place module on all pages except the front page:

$menu =& JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) return XXX;

Pre-JomGenius

If you have MetaMod 2.4 or more recent, try the "JomGenius" version instead of this one.

This assumes that you are using the standard “frontpage” component as the first menu item on your main menu. If you have changed to a different component for the first page on your site, then use the MetaMod Debug mode to find the right combination of $Itemid, $option and $view to identify the page and therefore not show the module on it.

Place module on all pages except the front page:

if (! ($view == "frontpage" and $option == "com_content" ) ) return XXX;

Place module only on the front page:

if ( $view == "frontpage" and $option == "com_content" ) return XXX;

There’s also an official Joomla way to identify the front page, by comparing the “active” menu to the “default” menu (i.e. one chosen for the front page). However this does not work in all cases (e.g. sometimes it activates when a form is “posted” to index.php), so the rules above are recommended.

Place module only on the front page:

$menu =& JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) return XXX;

Place module on all pages except the front page:

$menu =& JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) return XXX;