Last updated February 11, 2009. Created by tonycaine on February 11, 2009.
Log in to edit this page.
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;
}
?>
Comments
<?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
Front page block and exposed filters
My home page is a view with exposed filters. I want to display a block on the "true" homepage, i.e. www. abc123 .com, and not on the results when the filters are added, i.e. www.abc123.com/filtername?filter[1]=1
drupal_is_front_page() is still TRUE on these pages.
Thanks,
Danny
The answer to this question
The answer to this question was right in front of me all along, as provided by griera above. All that was needed was a little understanding of what the code was actually doing...
<?php
$match = FALSE;
$url = request_uri();
if (drupal_is_front_page()) {
$match = TRUE;
}
if (strpos($url, "?")) {
$match = FALSE;
}
return $match;
?>
thanks dannyjohnson1! I was
thanks dannyjohnson1! I was looking to do the same and found your solution to be very helpful.
Have you come up with any alternative solutions to the php code?
The above code seems to work
The above code seems to work fine and didn't cause any problems so that's what I went with in the end!
Hope it works for you too.