While working as a junior web developer, I spent most of my time with WordPress developing several WordPress websites for my clients. I enjoyed developing custom themes and addressing my client's requirements with all the cool plugins available for WordPress. Now that I have been working for a shop that focuses on Drupal, I have had to wrap my head around the differences between the two platforms. There are substantial conceptual differences between the two CMSs and I would like to share my experience working with Drupal. This post is geared towards WordPress developers who are interested in Drupal or just starting out. Hopefully I can shed some light on the main differences.
1. Core architecture: WordPress = WordPress Loop, Drupal = Content types, Node, Blocks, Views
âDrupal takes a totally different approach to its core architecture than WordPress does. WordPress is based on a blog system, and as Wordpress developers, we basically pass queries using WordPress loop to output content. I often struggled with WP Query and WordPress loop to sort and filter output. I often had to tweak parameters, and code custom PHP to add more filters that couldn't be done with built-in filters.
Drupal started as a small news site builder, but has evolved into a powerful content management framework. Drupal has extensive flexibility when it comes to outputting content from the database. It has a WordPress-like post display function (a.k.a node), and widget-like block system, but you can add more without touching any PHP code or custom MySQL queries. When you need to output a chosen fields data from different content types (like user's name, event date, and post summary etc), you just need to use the Views module to bind those fields and place it as a block anywhere you want.
This is quite handy when it comes to adding more data driven content to a website. Need to output specific data? No need to write a query, all you need is Views. Need to add an image field to block and put it under the content area? You just need to install the Bean module and create a custom block type and create a block placed under the content area.
A lot more work would be required for developers to do the same thing on WordPress unless there was already a plugin that does what you want it to.
As an example, I had some difficulty in handling WordPress loop on a project that was using a third-party event plugin. The loop with some filters went through from the beginning to the end of posts, and the latest six events were supposed to display on the front page. However, the frequency of events vary week by week, and that affected the number of event posts that were displayed. The filter that met my needs had to be hand coded
You can solve the same problem more easily with Drupal by setting up an event content type and making a View block with sorting and filters. The number of event posts displayed on the front page are not dependent on the event's frequency.
I don't blame WordPress for making things difficult. It's an excellent platform, and a really good CMS for personal website or businesses with simple functional requirement or functionality that can be accommodated by third-party plugins out of the box. It just needs more work to convert it into a rich web application, and Drupal with it's flexibility makes it easier to develop more robust features without using custom code.
2. Modules on Drupal are more heavily weighted than plugins on WordPress
You may have downloaded plugins to make your WordPress site fancier. Perhaps the Related posts plugin, an SEO plugin, a security plugin, or an image cropping plugin and so on. They are basically used to add more functionality, and in some cases, users need developer's hands to add more complicated features. To use WordPress as a simple blog site, users can immediately start to write a blog post after its installation.
Drupal also comes with a basic feature set out of the box, you are still able to write a blog post like WordPress using Article content type with Drupal's default state, but you will quickly encounter limits when you try to change layout, or add some custom content on a specific page or specific area with stock Drupal.
On Drupal Overview page, they explain, "Drupal isnât a prefabricated toy truck, but rather a collection of wheels, windshields, axles, frames, etc., that a toy maker can easily connect together."
This statement reflects a freshly installed Drupal site. It comes with minimal functionality out of the box and leaves it up to the developer to extend, install some modules and add more features.
For example, the Context module can control what blocks are displayed on a page based on context you make. For example, you can display a particular block on the front page, and another block on the About us page using the Path as a condition (There are taxonomy user roles, and other options available as conditions). This method allows us to display content on specific pages with minimal effort.
Digging around modules to achieve your goal is sometimes time-consuming, so I have listed some of the more popular modules used in Drupal websites. You may find some of them will help you to achieve what you want. Trying out some of these modules is a great place to start your adventure with Drupal.
Some of these modules are available as contributed modules for Drupal 7 but were so popular they have been built into Drupal 8 core. It takes some time to figure out what you can do with those modules, but once you are familiar with them, you will be able to choose an appropriate module quickly when trying to accommodate a functional requirement.
3. Concept of templates in Drupal
As I mentioned, Drupal's architecture is quite different form WordPress, so is the template structure. On WordPress, templates are based on index.php template, and separated by template hierarchy.
As wordpress.org explains, "WordPress matches every query string to decide which page is being requested, selects the template in the order determined by the template hierarchy, and looks for template files with specific names in the current theme's directory and uses the first matching template file as specified by the hierarchy."
In contrast, Drupal uses layer structure. Each template file is based on a specific area which is defined in .info file or configured on backend such as region, block, node, field. The templates are overlaid in a page, and the template at the top on the layer is used to output data. For example, field.tpl.php template is used to output field data, and other node data (wrapper html tags, title field, etc) is output by node.tpl.php, and page.tpl.php and html.tpl.php takes care of the outside theme outside of the node (content) area.
The illustration on "Overview of theme files" will help you to understand the structure.
4. Organize template files and code as Components
Compartmentalizing function into a module and storing them in a folder, or grouping template files in a folder is also easy on Drupal. With the default settings, Drupal organizes all the functionality separated into a module and they are stored in individual folders. Omega theme has a good component structure, and starting from a sub-theme of Omega for your custom theme will reduce the amount time required to organize template files and write preprocess functions.
That structure ensures high maintainability and scalability of your Drupal site. Furthermore, now Drupal 8 adopts SMACSS and BEM to conceptually categorize CSS rules and follows BEM naming convention. This makes it easier for developers to maintain organized component structure. Check out some of these resources to help you get a clearer picture.
5. Various ways to accomplish your goal
Drupal provides more flexibility than WordPress. That also makes it more difficult for beginners to learn Drupal. With freedom and flexibility comes a steeper learning curve.
There are, in fact, many ways to meet functional requirements with Drupal. The solution can depend on factors such as developer preferences/knowledge, your agency's workflow, preferred modules, etc. Given these variables and the flexibility, I found it hard to determine best practices for building out particular functional requirements.
I would recommend that you should start with as few modules as possible and do as much as you can with Drupal core. Additionally, take a look at Drupal projects that other experienced developers worked on (Which is easier if you work for a Drupal shop), or ask your developer friends to show you how they built their Drupal projects. The Drupal community on Drupal.org and IRC are fantastic and helpful resources when you have a question.
The best way to learn Drupal is to develop a simple website.
While I have been learning Drupal, I have watched a bunch of videos on Drupalize.me, and those videos were helpful to capture the basic knowledge of Drupal, but developing a small project was the best way for me to learn how to build/theme a Drupal site. (Don't start with anything too large or overwhelming)
If you are interested in Drupal, or would like to know how Drupal works, try picking up a simple WordPress theme and turn it into a Drupal theme. I found this to be a good beginning to my Drupal life. Enjoy!
I hope this post will give WordPress developers a little more info about the differences between Drupal and WordPress and where there are potential advantages of using Drupal.