O'Reilly logo

Programmer's Guide to Drupal, 2nd Edition 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, through 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.

Tip

If you are completely new to Drupal programming, you might find it useful to look at some Drupal code before or while reading this chapter. One suggestion would be to download Examples for Developers. You could try out the Page and Block examples, and take a look at their source code. Or, you might consider browsing through one of the Drupal core modules in the Drupal 7 modules directory or Drupal 8 core/modules directory, although they are not documented as tutorials. The Statistics module for Drupal 7 and 8 (which tracks view statistics and provides a block showing popular content) or the Email module for Drupal 8 (which provides a field for storing email addresses) would be good choices.

Principle: Drupal Is Alterable

Drupal is intended to be used as a platform for building web applications, so one of its fundamental principles is that nearly everything about it needs to be customizable, and ...

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