I've created custom print-html.node-type.tpl.php files for a few of my node types. This worked like a charm, straight out of the box.

Now I want to print out some different items in my print-html.node-type.tpl.php. For example, currently the username of the user who created the node is displayed at the top of the node. I've added some fields to the user object using profile.module; those fields contain the user's first name and last name. I want to display the first name and last name of the user who created the node, in place of the username.

At the moment, I do this by including the following in the print-html.node-type.tpl.php:

<?php $user_who_created_the_node = user_load($print['node']->uid); ?>

I can then print whatever part of $user_who_created_the_node I want to print.

I'm not a themer, but I'm pretty sure this is the wrong way to do things. Surely I should introduce new variables to a .tpl.php file using some sort of preprocess function? How should I implement this?

Comments

jcnventura’s picture

Status: Active » Fixed

Actually, that's the right way of doing things. The print module template mechanism is quite basic and the design objective is to make it extensible but not to create a duplicate of phptemplate.

As such, there's absolutely no way at the moment to add that kind of stuff from any preprocess function (which don't exist and aren't called). If someone takes the trouble to develop an easy-to-maintain template layer to the module, I would gladly accept it, but I don't think that will happen in the near future.

João

jim0203’s picture

Thanks João, good to know.

Status: Fixed » Closed (fixed)

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