I tried to restrict a block to show on the homepage only. With the option 'Show on the listed page only' I could not figure out how to indicate the home page. '/' did not seem to work nor did blank.

Finally I resorted to 'Show if the following PHP code returns TRUE' and inserted:

<?php
if ( empty($_SERVER['QUERY_STRING']))
  return true;
return false;
?>

Pretty ugly, isn't there is a better way than that?

Comments

avadhutp’s picture

Select "Show on the listed page only" and in the text box below type:

<front>
scoutbaker’s picture

As a relative newbie to Drupal, I find the descriptive text below the fields to often be helpful. I found this for the block visibility which mentions the <front> code:

Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are blog for the blog page and blog/* for every personal blog. <front> is the front page. If the PHP-mode is chosen, enter PHP code between <?php ?>. Note that executing incorrect PHP-code can break your Drupal site.

"Nice to meet you Rose...run for your life." - The Doctor

gregarios’s picture

Yes, but I use an internal page, http://kpbj.com/headlines as my home page. How can I make it only on the first page of these pages? (IE: not /headlines?page=1 etc.)

elugoye’s picture

Hi there....

We were having the same problem and found that if you get the node path of the page you want restricted it would do the trick.

So for instance if you do not want block or page to appear on the home page you would type: front and for any other page or block you would have to type in the node path:e.g node/2

I hope this helps you cause it worked a treat for us....

If not just get back to us and we can try work it out.....

Cheers

Shishir mishra’s picture

hi i tried this code , it worked but when i move from my home page and then go back on home the blocks doesn't appear. what should i do?