Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Strategies for keeping template files clean

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:03
    with Joe Shindelar
  • 0:07
    In this chapter, we're going to take a look
  • 0:10
    at some best practices for keeping the files and code
  • 0:12
    inside of our theme clean and usable and easy to maintain.
  • 0:16
    We're not going to cover anything really new, but what we are going to do
  • 0:20
    is take all of the things that we learned in the basic theming series
  • 0:23
    and everything we've learned so far in the advanced theming series
  • 0:26
    and make use of that to show you some best practice tips
  • 0:29
    for making maintainable themes.
  • 0:31
    We're going to go back to talking about the example

Strategies for Keeping Template Files Clean


This chapter shows some general best practices for keeping your template.php file clean as well as making it easier for designers to work primarily with the template files when possible to avoid them having to make too many changes to template.php. Specifically, some HTML classes are removed from the ninesixtyrobots_comment_form() function in template.php and moved to the comment-form.tpl.php template file, which is specified as an option in the ninesixtyrobots_theme() function. The rendering logic is also removed from the theme function and into a preprocess function so that it can be passed in as a variable to the new template file.

Additional resources: