Why doesn't this work for me? I can't use <front> because I also need the content type logic.

$match = FALSE;
$types = array('resource' => 1); //custom node type
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;  //display if recource node
  }
}
if ($is_front) { 
  $match = TRUE; //display if front page, doesn't work as I expect
}
return $match;

Comments

ziobudda’s picture

return $match;

Is your code into a function ? If yes have you tried to insert

global $is_front

at the top of the function ?

M.

Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it

jo1ene’s picture

I now have this in the block visibility settings...

global $is_front; //per your suggestion
$match = FALSE;
$types = array('resource' => 1); //custom node type
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;
  }

}
if ($is_front) {
  $match = TRUE;
}
return $match;

...and it still doen't work.

Advanced Web Design

styro’s picture

rather than a global variable. This is where it gets added to templates:
http://api.drupal.org/api/function/_phptemplate_default_variables/5

As you can see it contains the output of drupal_is_front_page() - you could just use that function in your check instead.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

jo1ene’s picture

This is what I have now and it works fine. Thanks!

$match = FALSE;
$types = array('resource' => 1); //custom node type
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;
  }

}
if (drupal_is_front_page()) {
  $match = TRUE;
}
return $match;

Advanced Web Design

ziobudda’s picture

I will never stop to learn in this forum :)

M.

Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it