The following error message is shown when printing a page where e view has been included by EVA module and that view lists content with 'print' view mode.
Notice: Undefined index: #print_format in print_preprocess_node() (line 119 of /var/www/drupal/sites/all/modules/print/print.module).
I will shortly provide a patch to solve this problem, which simply checks if $variables['elements']['#print_format'] (line 119 of print.module) is set before trying to access it. I don't know if the array key not being set is a problem in another module or if Drupal allows it, but I think that simply checking if a key is set before accessing it can only be a safe improvement for Print module.
Comment | File | Size | Author |
---|---|---|---|
#1 | print-undefined-index-1619164.patch | 1.53 KB | Norberto Ostallo |
Comments
Comment #1
Norberto Ostallo CreditAttribution: Norberto Ostallo commentedThe patch.
Comment #2
jcnventura CreditAttribution: jcnventura commentedIndeed, however if '#print_format' is not defined, we shouldn't be doing anything so the best would be to do:
Can you test using the above instead?
João
Comment #3
Norberto Ostallo CreditAttribution: Norberto Ostallo commentedI just thought to leave the line
$variables['theme_hook_suggestions'][] = "node__print";
in order to enable the 'node__print' theme suggestion.
Anyway I confirm that it perfectly works also your way: indeed it was the first I tried and tested.
Comment #4
jcnventura CreditAttribution: jcnventura commentedBasically, that node--print.tpl.php suggestion is there to allow you to use your own module-specific version of the node template.. The call to render the node content will include the '#print_format' variable if it comes from the print module.
I though the existing condition - checking if view mode is 'print' - was enough, but of course as I recycled the 'print' view mode from the core book module, you can actually be using the print build mode and not be using the module.
It's one extreme case: that you want to use book's HTML traversal while having the print module installed and you have created a node--print.tpl.php file - the content of the nodes of the HTML traversal would use the print template which would be unexpected.
Comment #5
jcnventura CreditAttribution: jcnventura commentedAnd this applies to 7.x-1.x also...
Comment #6
Norberto Ostallo CreditAttribution: Norberto Ostallo commentedI've never used the book module, but that's clear to me now. In this case what you were proposing works just as well.
Let me know if you need me to provide a patch for that too.
Comment #7
jcnventura CreditAttribution: jcnventura commentedhttp://drupalcode.org/project/print.git/commit/9d735d8