Last updated 15 October 2008. Created on 15 October 2008.
Edited by dman. Log in to edit this page.

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.


// 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)));

Looking for support? Visit the forums, or join #drupal-support in IRC.


japanitrat’s picture

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

Parkes Design’s picture

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

/* 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.

anonymous07’s picture

Thank you for this ... it appears to work fine.

paskainos’s picture

Very nice! This is a great catch-all snippet that can also be used in Context (+ Context PHP). I know - code in db = big frowny face. Only in VERY limited circumstances. ;)

mw4ll4c3’s picture

The following will return TRUE on node/%, node/%/view, admin/(build)/block*


switch(arg(0)) {
case 'node':
  return (
    && (
      (arg(2) === NULL)
      || (arg(2) == 'view')
case 'admin':
  return (arg(2)=='block');
return FALSE;