The watermark component was updated in commit 8e62f13 to add a "preview" watermark, but it looks like the $preview variable was not included in zen/template.php, resulting in:

"Notice: Undefined index: preview in zen_preprocess_node() (line 328 of ... zen/template.php)"

and, "Notice: Undefined variable: preview ..." in node.tpl.php or comment.tpl.php wherever $preview is called.

I experimented but could not get the "preview" watermark to work :-(

CommentFileSizeAuthor
#3 zen-undefined_preview-2333899-3.patch670 bytesprogpapa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

echoz’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

I've discovered this only occurs placing a block in the header region (?!) Still a mystery, will report back when I know more.

echoz’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

Still there, just some inconsistency of the notices appearing.

progpapa’s picture

Status: Active » Needs review
FileSize
670 bytes

I think this is because $variables['preview'] is only set if you click on the "Preview" link in the node edit form, otherwise it is undefined.
The attached patch worked for me.

The reason for the inconsistency might be that you are using Panels (+ Page Manager?) and rendering is not always going through the Zen files.

makbeta’s picture

Thank you @echoz, the patch worked for me as well.

davidneedham’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #3 seems to work for me as well.

davidneedham’s picture

I just applied the patch in #3 on a different website and it worked there as well.

stpaultim’s picture

I applied the patch from #3 and it worked for me.

dudeonthebayou’s picture

I applied patch from #3 also on the latest Zen 7.x-6.x-dev and it fixed the issue.

Christopher James Francis Rodgers’s picture

With "Thanks" to those who posted above.

Zen 7.x-6.x-dev (2015.03.01)

Applying the patch code manually with a text editor.

Edit the file "template.php" in the root
of your "Zen" base-theme directory;
NOT the file in your Zen sub-theme folder.

(approximately line 322)
Go to the blank-line just above the line:

// Add pubdate to submitted variable.

Insert these 2-lines of code:

// Set preview variable to FALSE if it doesn't exist.

$variables['preview'] = isset($variables['preview']) ? $variables['preview'] : FALSE;

...Granted, the first of those two lines is just a comment,
and is not critical.

The line of code
$variables['preview']... ... ...['preview'] : FALSE;
is a single line of code; even though it might not appear that way
in the code box above, and in the code box below.

Your code should now look like this;
except that some single-lines-of-code
might be 'wrapped' if the box below is too small.

...

  // Add $unpublished variable.
  $variables['unpublished'] = (!$variables['status']) ? TRUE : FALSE;


  // Set preview variable to FALSE if it doesn't exist.
  $variables['preview'] = isset($variables['preview']) ? $variables['preview'] : FALSE;

  // Add pubdate to submitted variable.
...

The spaces at the beginning of each line are not critical.

After uploading the new file to my website,
I refreshed the open page
I was originally viewing with the error message,
and although the message did Not go away,
it did go away when I refreshed the page a second time.

=== My notes:

My error line numbers do not match those
of the others who posted above, so even if I knew how to,
I am guessing that the posted patch would not work
for the latest development release,
Zen 7.x-6.x-dev (2015.03.01),
since patches add code to specific file line numbers;
number which appear to have changed because of subsequent
changes to the file.

For the benefit of Google, and other search engines,
the error codes are now:

Notice: Undefined index: preview in zen_preprocess_node() (line 324 of ... template.php).

Notice: Undefined variable: preview in include() (line 29 of ... node.tpl.php).

I did not want to take a month out of my life
to learn how to apply patches to Drupal
using additional new programs I know I have to find,
install, and learn how to use.

This Drupal page "Applying a patch manually"
https://www.drupal.org/node/534548
is NOT a clear guide, but it did give me the confidence
to figure out how to apply
the Zen patch changes recommended
from the work and generosity
of our fine community members who posted above.

: o )

Thanks again.

  • JohnAlbin committed d352778 on 7.x-5.x authored by progpapa
    Issue #2333899 by progpapa: Undefined variable $preview for watermark
    

  • JohnAlbin committed 932daf9 on 7.x-6.x authored by progpapa
    Issue #2333899 by progpapa: Undefined variable $preview for watermark
    
JohnAlbin’s picture

Status: Reviewed & tested by the community » Fixed

Fixed! Thanks for the patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

waqarit’s picture

Thanx it has worked for me :)