Block visible if on front page
Last modified: February 11, 2009 - 19:53
sourced from node http://drupal.org/node/196158 . Summary: cannot use $is_front in block visibility snippets as is templating variable.
To make block visible on front page add following snippet to blocks 'Page specific visibility settings' and make sure using as PHP
<?php
if (drupal_is_front_page()) {
return TRUE;
}
?>or to hide it the reverse
<?php
if (drupal_is_front_page()) {
return FALSE;
}
?>
<?php if
<?phpif (!drupal_is_front_page()):
?>
I cannot hide block in pages 2, 3, 4, etc.
I tried to show a block "just" in the front page.
I tried in the block visibility settings with
<front>and with php<?phpif (drupal_is_front_page()) {
return TRUE;
}
?>
This works ok to avoid the block appear in other pages/nodes/sections.
But if the home page has many articles, and because of that it is paging,
the block appear in home page but also in page 2, 3, 4 etc. as if these were also the home page.
Is there a way to avoid this behavior?
I want the block shown just at the front page.
www.guillermoriera.com
Block visible in home page, and hidden in following pages
<?php
$match = FALSE;
$url = request_uri();
if (drupal_is_front_page()) {
$match = TRUE;
}
if (strpos($url, "node")) {
$match = FALSE;
}
return $match;
?>
With this code you can keep a block displaying just in the front page, avoiding been repeated in the following pages #1, #2, #3, etc. in a home-multipage situation.
www.guillermoriera.com