Architecture: Site or Functionality

Posted by jaffar on July 24, 2013 at 2:45 AM

Site architecture includes how the site works, the number of modules, and how they interact.

Best Practice

Keep your site lean, using the minimal amount of code and fewest number of modules necessary. Use contrib

modules whenever possible rather than writing custom code. Become expert at key contrib modules, such as

Views and Panels. Follow Drupal standards for custom code. Reevaluate your architecture periodically.

Mistake: Too many modules. More than 200 modules indicates a need for analysis to be sure all are necessary.

Example 1: Original plan included multiple languages, but site ended up in English only.

Example 2: Original plan anticipated need for numerous roles, but most not used.

Solution: Reevaluate your site periodically, and disable or remove unused modules.

Mistake: Creating custom code when a contrib module already does the job well.

Example: Custom module to create forms on the fly that can be sent by email to site admins.

Solution: In this case, the well-tested Webform module provides this functionality, along with flexibility for site

admins. Be sure no contrib module already does what you need.

Mistake: Hacked core or contrib modules. Behavior will be unpredictable. Updating is difficult.

Solution: If core or contrib doesn’t do quite what you need, build a custom module using hooks to alter

behavior. If you inherit a site, use the Hacked! module to find altered code (see Recommended Tools).


Mistake: Custom code using the wrong hooks or using the Drupal API incorrectly.

Example 1: Using hook_init, which loads on every page, for something only used on the home page.

Example 2: Custom modules with hardcoded strings for nids, tids, and vids. When these change in the

future, troubleshooting the cause of resulting problems is very difficult.

Solution: Plan carefully when using custom code. Find the right hooks and syntax using drupal.org’s API

documentation at [http://api.drupal.org/api/drupal].

Recommended Tools:

Simplytest.me [http://simplytest.me].

On this site, simply enter the name of a Drupal module. The site will spin up a Drupal instance for you to test

the module for 30 minutes.

Hacked! module [http://drupal.org/project/hacked]

This module scans your Drupal installation, including contrib modules and themes, and determines if they

have been changed. Used with the Diff module, result screens will tell you the exact lines that have changed.

Not to be used on production sites.

Categories: None

Post a Comment


Oops, you forgot something.


The words you entered did not match the given text. Please try again.

Already a member? Sign In