Hi everyone,

I was wondering is there a way I can have a menu always appear if the content is of a particular content type? Right now everytime I create a node of type X, I then have to go into the menu block, go to configure, and add the URL of the node I just created so the menu appears on that node page.

Thanks
-Nate

Comments

zbricoleur’s picture

Create a page.tpl.php file for that content type (see http://drupal.org/node/249726)

Add a new region to your theme's .info file.

Add that region to the new page.tpl.php you've created, where you want the menu to appear.

Go to admin/build/block and add the menu to that new region, and configure the block to show up on all pages (it will only show up on the pages that use the new template).

ore’s picture

Or if you don't want to create template files you can create a manual menu block and just insert the following code for page specific visibility settings. select "show if the following php code returns TRUE" . Not a very nice solution but it works. Node load is an expensive call but it should be a cached call so shouldnt impact to much.

<?php 
$node = null;
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
  $nid = arg(1);
  $node = node_load($nid);
}else {
return false;
}
if($node->type == "CONTENT_TYPE_NAME" || $node->type =="CONTENT_TYPE_NAME")  // appears on two different content types. remove the || onwards  for only one.
return true;
else 
return false;


?>

redbull247365’s picture

Thank you for these posts...... Hmmm a bit more involved than i had suspected I would think something like this would be pretty easy to do. but I guess a new page.tpl.php file is in order.

Thanks for the help guys appreciate it.