I am working on displaying a custom menu block based on all of the pages belonging to an assigned category. The problem is that the block is showing up on every page, not just the pages in the category. I've selected the correct option and put in the code below - "Show if the following PHP code returns TRUE (PHP-mode, experts only)".

Since I only need 1 category specified, I'm using this code with the category specified as "my_category". Then in my list of categories, I have a category named "my_category". (no quotes)


$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1); 
$type = db_result(db_query("SELECT type FROM {node} WHERE nid=$nid"));
  if ($type == 'my_category') {
    $match = TRUE;
  }
}
else {
  $match = FALSE;
}
return $match;

Any guidance would be appreciated.

Comments

cschall’s picture

I didn't add in the php tags. Duh! Works great.