Skip to: Site menu | Main content

beginner

Understanding the Drupal Way - Specificity

In the post on making output themeable I discussed the example of overriding a template file for a flag. The template file I overrode was a generic definition of the markup for all the flags on a site. I can create a template file that overrides a specific flag.

Understanding the Drupal Way - Alters

In Drupal an alter is intended to provide a way to modify an object during a point in the execution of a certain event or process. Alters are defined within individual modules. Those modules then give the opportunity for other modules to "alter" an object by calling drupal_alter at the appropriate time.

Understanding the Drupal Way - Themeable Output

The whole point of creating a custom theme is to get a website to look the way you want it to. So, it's important for the output that modules generate to be themeable.

I will give a simple example of modifying the markup that is used to display some links. The Flag module provides a mechanism to do things such as "liking" a post or reporting a post as spam. A post may have a link for each flag that is associated with it.

Understanding the Drupal Way - Hooks

In Drupal a hook is intended to provide a way for actions to be triggered during a point in the execution of a certain event or process. Hooks are defined within individual modules. Those modules then give the opportunity for other modules to "hook into" their processing by calling the hook at the appropriate time.

Understanding the Drupal Way - Collaboration

Collaboration is an important part of the Drupal community. The principle of collaboration applies equally to how people in the community engage with each other and to how modules are written.

I mentioned the Libraries API in a spearate post when I discussed creating a slideshow. The specific example was that you would use the Libraries API and you would also use the jQuery cycle plugin as part of creating a slideshow.

Understanding the Drupal Way - Extensibility

When creating a module for Drupal it is important to write the module so that it is extensible by other modules. I will talk about ways that it is possible to do this in other posts.

I mentioned a couple of examples of extensibility in the Modularity post. In my example of adding a slideshow to a Drupal site I said that you would likely use Views, Views Slideshow, custom content types and custom fields.

Understanding the Drupal Way - Modularity

I mentioned in a previous post that Drupal is a modular framework. The idea is that modules should be designed to do one (small) thing well. This is in contrast to the monolithic approach that plugins employ in other content management systems.

For example, if you want to add a slideshow to a WordPress website you can download a single plugin from the WordPress official site. When I visited the WordPress site and searched on slideshow I got over 500 results!

Understanding the Drupal Way - Subthemes

In order to retain the changes you make to a theme like the Bartik theme you need to create a custom subtheme. Use the Bartik theme as a base theme.

It's beyond the scope of this post to go into detail about Drupal's theme layer and how to create custom subthemes and themes. So, I won't explain everything you have to do. You can find more information on Drupal.org.

Understanding the Drupal Way - Basic Drupal Principles

The first thing to understand about Drupal is that it is based on a modular approach to providing functionality. I will elaborate on this further in another post.

The point I want to focus on in this post is that every module on a Drupal site is a first-class citizen. There are no "special" modules that can so something that other modules cannot do.

Three basic types of modules are:

  1. core
  2. contrib
  3. custom

WTF: How do I get Drupal to put placeholder text inside my textfield?

What's that feature: the #attributes key.

Perhaps you have written your own javascript code to determine that an empty textfield does not have focus, and in such a situation place some placeholder text in the field. If you are using the FAPI there is an easier way. You can do this:

Credits: XWeb | Chris Herberte | Andreas Viklund