So I see all kinds of examples code such as the following:

  // Only show if $match is true
  $match = false;

  // Which node types
  $types = array('Project Page', 'Project Folder');

  // Match current node type with array of types
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $node = node_load(array('nid' => $nid));
    $type = $node->type; 
    $match |= in_array($type, $types);
  }

  return $match;

All these examples though seem to be when Drupal is not using clean Urls. How exactly should this be modified for clean URLs?

Comments

foxtrotcharlie’s picture

Even with clean urls, when viewing a node, the underlying path (although not visible in the address bar) that the arg() function uses will be something like "node/46", so this code will work.

To check what the arg() function will ouptut, just place this temporarily in your node.tpl.php file:

<?php print '<pre>';?>
<?php print arg(0);?><br />
<?php print arg(1);?>
<?php print '</pre>';?>