Confused!

This is what I have :

if($is_front){
return false;
}else{
return true;
}

Not so complicated. (Yes I know that I could just exclude the front page but there are other conditionals to add once this works)

$is_front shows as true on the home page and false on every other page (who'd of thunk it?) but the block shows on all pages. And I am not sure why....

thanks

Nick

Comments

nirmal_george’s picture

You can use <front> instead of php code , and select 'Show on every page except the listed pages.' in Page specific visibility settings. No need to use PHP code.

Abhijeet Sandil’s picture

$is_front is set only when you are on the front page of the site. The $is_front variable is not set for "listing" pages.

Use

if($page==0) instead of if($is_front).

$is_front is set strictly for the front page

use <front> instead of php code is always better option for page specific visibility settings.

cog.rusty’s picture

The $is_front variable is only defined in page templates in the theme. It is undefined in your blocks.

In blocks you can use drupal_is_front_page()

nicknewbie’s picture

@nirmal - yes, that is what I meant. If I use <front> I cannot add other php conditionals in.

@ abhijeetsandil - well, $is_front is true on the front page and false on the other pages. I var_dumped it to check this. My understanding was that $page==0 would specify all the front-page-like pages. I read this but am not 100% on what it actually means...

@cog.rusty - ah a light-bulb moment ! Yes, of course. Thank you.

cog.rusty’s picture

By the way, $page in a node template is TRUE when you are in a full node page and not in a teaser list page.
See:
http://api.drupal.org/api/drupal/modules--node--node.tpl.php/6
http://api.drupal.org/api/drupal/modules--system--page.tpl.php/6