Skip to: Site menu | Main content

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!

If you want to create a slideshow in Drupal, you will download a number of contributed modules. At a minimum you will use Views, Views Slideshow and the Libraries API. You will also need to download the jQuery Cycle plugin and place it in the appropriate place in the directory structure (sites/all/libraries/jquery.cycle). There is a good chance that you will create a custom content type and add fields to it. This may seem like a lot of work when you are first getting started with Drupal. There are a number of advantages to using this type of modular approach, though.

One advantage of creating a small module is that it is much easier to debug a problem on the site. As long as a module is not a dependency of another module, you can disable that module to see if the problem goes away. If the problems remains, then you know the disabled module is not the culprit. If you had a single large module, disabling it would likely mean that you couldn't even test the functionality any more because disabling the module also removed all of the functionality.

Another advantage is that you can see performance gains on a production site by disabling the administrative modules. For example, the Views suite of modules breaks things up into administrative interface types of modules and key logic types of modules. As you are building a site, you will enable the administrative interfaces and when you launch the site you disable them.

Finally, doing things this way provides a lot of power and leverage. I'll talk about this more in other post.

If you want to learn more about Drupal you can take my course "Drupal for Beginners" for just $5.

Credits: XWeb | Chris Herberte | Andreas Viklund