In my print_mail e-mails, I would like to display node teasers, as themed by my existing node-type.tpl.php files. Is this possible?

I tried to do this by setting Send only the teaser in print's e-mail settings. However, the module seems to then build the node as configured in its Print Display Settings. I would like, however, to use my node templates, as they already have a themed display that runs if $teaser = TRUE.

I imagine I am doing something wrong, but can't figure it out. Thanks in advance all!

CommentFileSizeAuthor
#5 print-template_teaser-707484-5.patch440 bytesjfrederick
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jfrederick’s picture

I think the code that is causing my difficulty is in print.pages.inc (587-591):


$content = theme('print_node', $node, $teaser, TRUE, $format);

if($teaser) {
  $content = $node->teaser;
}

The call to the theme function does fill $content with templated output, including a teaser if that is passed, but then if teaser had indeed been passed, the themed output is overwritten with the default print display style (drupal_render($node->content)).

jfrederick’s picture

Status: Active » Closed (works as designed)

My solution for this problem:

  1. In the module, set the e-mails to send full nodes. That way, $content = $node->teaser does not get called to overwrite the themed output.
  2. Make the theme() call actually return teaser output, despite being called with $teaser = FALSE. In my template.php add this code:
    function mytheme_preprocess_node(&$variables)  {
      if($variables['type'] == 'mail') {
        $variables['teaser'] = TRUE;
      }
    }
    

This makes two settings in the module stop functioning: in /settings/print/email Send only the teaser and Enable teaser/full mode choice. No matter what I now check for these, it will always send the teaser. Which is okay for me, but beware of the downfalls of a hack!

jcnventura’s picture

Status: Closed (works as designed) » Active

I don't test the teaser-only mode often.. That code that overwrites the content var with the teaser is actually older than the call to theme_print_node().

This needs a proper in-module fix.

jfrederick’s picture

I am trying to figure out how to fix this, so I could submit my first patch. But what I don't understand, is what the teaser option should do.

Should the teaser option use the Print Build Mode, as it does now, or should it use the Teaser Build Mode?

As a solution, what is the downfall of simply axing

if($teaser) {
  $content = $node->teaser;
}

?

jfrederick’s picture

Version: 6.x-1.7 » 6.x-1.x-dev
Category: support » bug
Status: Active » Needs review
FileSize
440 bytes

Here is the patch I mentioned. How it affects use:

If you are sending e-mails as full nodes, everything remains the same.

If you are sending e-mails as teasers, your nodes will be templated by node.tpl.php, node-type.tpl.php, etc.

The D7 branch of Print already acts this way.

Thanks for the awesome module!

jcnventura’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Closing all issues related to the Drupal 6 version of the print module.