O'Reilly logo

Programmer's Guide to Drupal by Jennifer Hodgdon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Drupal Programming Principles

Experienced programmers learn, from training and experience, a set of principles and best practices to apply whenever they approach a problem they want to solve with programming. These include general practices such as "Comment your code" and "Choose clear variable names," which apply to all programming languages and situations, and some that are specific to a particular domain. Drupal has its own set of programming principles (covered in this chapter); learning them and following them should help you be a more effective Drupal programmer.

Note

If you are completely new to Drupal programming, you might find it useful to download the Examples for Developers project from http://drupal.org/project/examples before reading this chapter. Try out the Page and Block examples, and take a look at their source code. Then come back and you’ll have a little more context for learning these principles.

Principle: Drupal Is Alterable

Since Drupal is intended to be used as a platform for building web applications, one of its fundamental principles is that nearly everything about it needs to be customizable, and it needs to be customizable without having to edit its base source code. Since you’re not supposed to need to edit the base code to build any type of web application with Drupal, both Drupal core and contributed modules are (ideally) fully alterable, meaning that they provide hooks that you can use to customize their behavior and output.

The term "hook" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required