Customizing the node template

Drupal: 24m
Video Series
Information

Walks through the process of copying the default node.tpl.php file from the core node module into the theme, and then customizing the output specific to individual in order to match the design. See how to add specific variables, when to use conditional if statements and the best way to debug and iterate through this process.

Discussion

Comments on this video

You need to be an active subscriber to comment. or .

For the insanely anal watcher, on the "customizing the node" video, the tag field is hidden from display only on the node page. At this point, it is still visible on the teaser on the home page.

I found out a way to present the field tags inline.
Hopefully it will help the ones trying to do so.
(i was not able to do in the preprocess function but in the node.tpl.php)
Here is my piece of code
$tags ="";
for($i=0;$i".$term."";

}
echo $tags;

@emvp84, looks like someone is trying to get extra-credit. Displaying the terms inline is something that we actually tackle in our upcoming Advanced Theming series. It's also a tricky one because there are a number of different ways that it can be done. We actually had some internal debate about what method we wanted to use. The video containing our solution should be out in the near future so keep your eye's peeled.

We end up doing it inside of our themes template.php file so that we can keep the PHP heavy logic out of our template file and just use a simple print statement in our template file. However, in order to do that you'll need to know how to use preprocess functions. Again, coming soon. It's similar to Drupal 6 however so you can checkout this video for now: Adding new template variables

Also, pro-tip. You probably want to make sure your $term is wrapped with check_plain($term) for security purposes, or use the l() helper function for outputting your links in a safe and secure way.

@joe, thanks for the info. I was indeed trying to get the extra credit and fully understand several things that can be done. Unfortunately I had no luck until recently and found that "way" on doing things. I acknowledge that its not the best way or even the efficient way, but it get the job done.

Thanks for the pro-tip, im still new on this super cool things, but im getting my way there and trying to do several things at one.. (need to get focus on only one to improve hehe).

I wanted to do everything in the template.php within a pre process function but the one that i was using did not worked at all and i was getting frustrated so bought the book "The Definitive Guide to Drupal" and that helped to understand more variables in a different perspective.

We are getting there, and i just wanted to share my knowledge. I think about giving to the community what you learn so not only seeing the videos but also sharing with them.

This is my third post and hopefully i can do even more to help the other people and teams that are learning one step at the time.

Again, i will try your pro-tips and read what they do and implement them :)
-enrique

Lullabot logo

Lullabot has trained thousands of Drupal developers & guided the development of some of the largest Drupal websites.