get variable indicating node preview mode (D7)? I would like to display a specific message to users when they are previewing a node they are submitting. So I thought I would use a block with PHP code, using some info indicating that the node is being previewed.
Unfortunately, I cannot get it working. I have tried these conditions:

if ($variables['view_mode'] == 'preview') ...

I get this error:


  Notice : Undefined variable: variables in eval() (line 4 in
  /.../modules/php/php.module(80) : eval()'d code).


Tried this too:
if ($node-&gt;in_preview == TRUE) ...

I get these errors:


  Notice : Undefined variable: node in eval() (line 5 in /.../php.module(80) : eval()'d code).
  Notice : Trying to get property of non-object in eval() (line 5 in /.../php.module(80) : eval()'d code).


I guess I have to declare the variable before, but how? I thought that since the 
node form is rendered anyway, the needed variable was available?
The variable that inside node.tpl.php says the view mode currently used for the node is $view_mode, but that variable is not used when Drupal is displaying a preview of the node. To know that, you can:


Check the value of $node-&gt;in_preview; when that value is TRUE, Drupal is displaying the preview of a node.
Check that $classes contains the string 'node-preview', such as with the following code.

if (strpos($classes, 'node-preview') !== FALSE) {
  // Drupal is showing a preview of the node.
}



Drupal already shows a message when the user is watching the preview of a node, anyway.


  The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.