Block visible only on node VIEW pages, not node/add, node/n/edit

Last modified: October 15, 2008 - 21:24

by request

I have a block that I want to show to the end user on all nodes:

So I enter:
node/* as the path to allow the block to be visible there

However I *do not* want the block to be displayed when I create a node. The path will be something like node/add/story. This matches node/* unfortunately.

Answer:

<?php
// Only show on true node VIEW pages. Not node/add or node/n/edit etc
return (arg(0)=='node' && is_numeric(arg(1)) && (!arg(2)));
?>

Doesn't work for node/%/view

japanitrat - January 30, 2009 - 07:23

Doesn't work for node/%/view ...

Try This :-)

Parkes Design - February 10, 2009 - 14:40

Change user to node and you should have the same effect.

<?php
/* this block will show on user/2 but not on user/register or user/2/edit. First arg must be "user", second arg must be a number, third arg must be empty. */
if ((arg(0) == 'user') && is_numeric(arg(1)) && (arg(2) == NULL)) {
   return
TRUE;
}
else {
   return
FALSE;
}
?>

Let me know if it works.

 
 

Drupal is a registered trademark of Dries Buytaert.