I need to reference a node variable in the block visibility. Basically i have a block that i want to hide when a certain node variable does not contain content.

i have been struggling with this for days so help would really be appreciated.

Comments

nevets’s picture

It sounds like the block should only show for pages displaying a node of a certain type and only if a field is non-blank. If this is correct, two thoughts

a) If you are displaying the field (the non-blank one) you could use CCK Blocks.

b) Otherwise this should help

<?php
$ret = FALSE;
$node = menu_get_object();
if ( !empty($node) ) {
  if ( your field is not empty ) {
    $ret = TRUE;
  }
}

return $ret;
?>
UNarmed’s picture

This is what i ended up doing and it got the job done. I am new to php so yours is probably a lot cleaner. Thanks for the reply, i will give it a try =]

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
  $nid = (int)arg(1);
  $node = node_load($nid);
}

if($node->field_client_feedback['0']['value']) {
    return TRUE;
  }
  return FALSE;


?>