I'm using print module for generating a PDF file. Here, the node that I'm printing has a field that lists all the taxonomy terms for that specific node.

When the page is printed, the taxonomy terms are displayed in an unordered list with bullets, leaving an empty line between field name and taxonomy terms as:

Field name: 

 - term1
 - term2

But, I wish to display the terms next to field name in the generated pdf. I tried using taxonomy menu module, but i anticipate it doesn't work with print module. Is there any way to get this done.

1 Answer 1


If you go to the display settings for your node (eg. admin/structure/types/manage/article/display) and in the "Custom display settings" fieldset check the box for "Print" and the save. Then click the tab for the "Print" display settings.

Then configure your field with an inline label.

If this is not sufficient for your requirements you could also then override node or field templates specifically for that print display mode.

I can provide more information on that if you require it.

For node and field templates you can either use an if statement in the template to specify a specific view mode or you can add specific template suggestions so that you can have specific templates, like node--print.tpl.php

For the if statement method there are variables already available in those tempaltes:


<?php if ($view_mode == 'print'): ?>
  Your code goes here.
<?php endif; ?>


<?php if ($element['#view_mode'] == 'print'): ?>
  Your code goes here.
<?php endif; ?>

Or you can add template suggestions like this in your template.php file:


 * Variable preprocessor for the node templates.
function THEMENAME_preprocess_node(&$vars) {
  // Template suggestions for node--VIEW-MODE.tpl.php.  
  $vars['theme_hook_suggestions'][] = 'node__' . $vars['view_mode'];
  // Template suggestions for node--NODE-TYPE--VIEW-MODE.tpl.php.  
  $vars['theme_hook_suggestions'][] = 'node__' . $vars['node']->type . '__' . $vars['view_mode'];


 * Variable preprocessor for the node templates.
function THEMENAME_preprocess_field(&$vars) {
  $element = $vars['element'];

  // Template suggestions for field--VIEW-MODE.tpl.php.  
  $vars['theme_hook_suggestions'][] = 'field__' . $element['#view_mode'];
  // Template suggestions for field--FIELD-TYPE--VIEW-MODE.tpl.php.  
  $vars['theme_hook_suggestions'][] = 'field__' . $element['#field_type'] . '__' . $element['#view_mode'];
  // Template suggestions for field--FIELD-NAME--VIEW-MODE.tpl.php.  
  $vars['theme_hook_suggestions'][] = 'field__' . $element['#field_name'] . '__' . $element['#view_mode'];

Those are examples. You can make other suggestions based on pretty much anything you want.
You can also just do a specific template suggestion for the print view mode instead of doing dynamic ones for all view modes like the above examples.
If using the above examples be careful that you don't have conflicts, for example if you have a node type that is the same as a view mode.

  • How can i override node or field templates? Do i need to create something like node--print.tpl.php
    – GIRI
    Apr 2, 2015 at 9:26
  • I added examples above.
    – rooby
    Apr 4, 2015 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.