Here are two very useful snippets that you should keep somewhere easy to access and safe:

To display the block ONLY on Node View but not on Node Edit:

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

The same principle works with ‘user’ as well if you want the block to show only in user profile but not in registration, request password screens.

Source: Drupal PHP snippets

To display the block ONLY on logged-in user's account page but not on other user's account page:

global $user;
// Return TRUE if we have a user viewing her/his own user profile.
return $user->uid && arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid;

by Nedjo

Comments are closed.