Welcome to FFW’s new company site! I’m especially excited about this project because we built it in Drupal 8. FFW made this decision because of our commitment to Drupal, since Drupal 8 represents an important next step in the evolution of digital experience delivery.
Drupal 8 features over 200 improvements from the widely-used Drupal 7, including complete mobile compatibility, faster performance, a more modern development approach, and an improved user interface for content editors.
Additionally, Drupal 8 packs more functionality into core than any previous versions of Drupal. With this in mind, we agreed to try to stick with core modules and use contributed modules as sparingly as possible as we worked on the new FFWagency.com
In this blog series, I will highlight some of the tasks I completed and the approaches I used.
Before delving deeper into our approach, I’d like to tell you a little bit about my involvement with Drupal. I have provided Drupal 8 development training, contributed to writing some Drupal 8 core patches, mentored and supported FFW developers, encouraged company developers to contribute to Drupal Core, and maintained the contributed Drupal Console project. Based on my involvement with Drupal 8, I was than eager to begin when asked to participate in the development of the new FFW website.
Building a Drupal 8 Custom Module
Mautic.org marketing automation service implementation
Mautic is an open-source marketing automation software for email, social media and more. Organizations can build forms, campaigns, and gather reports on their marketing efforts using Mautic.
Create a module
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="generate-module.sh"]
Module generated code:
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="ffw_mautic.info.yml"]
Create a Twig template.
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="automatic-form.html.twig"]
Create a Configuration Form to set custom data required to interact with mautic service.
Form generated code:
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="SettingsForm.php"]
Create a block plug in to render the template on a region.
Plugin Block generated code:
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="MauticFormBlock.php"]
Required code changes to render the Twig template added manually.
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="changes.php"]
Create a filter plugin to render the template on the content area.
[gist-embed data-gist-id="dcdacb1f918c5453940d" data-gist-file="MauticFormFilter.php"]
This plugin filter was coded manually, since no command generator available for this component, at the moment of creating the module.
Drupal 8 is more technically advanced compared to its predecessor. Now, writing a module involves much more boilerplate code, and there is a lot you need to know to start building a new module.
It’s also important to note that Drupal 8 uses an Object Oriented Programming paradigm, which means you’ll work with Classes that extend or implement other Classes. Using an IDE is highly recommended to save time while navigating on those Classes and auto-complete the methods Classes provides. An IDE will also provide syntax highlighting and code indentation, among other features.
Using a tool like Drupal Console can help you manage this complexity and develop more quickly and intelligently by leveraging modern PHP practices.
Exporting and importing configuration is a great Drupal 8 feature. Even when every module could behave as a feature, including configuration YAML file(s), it can get imported when installing the module. This functionality introduces issues when module is uninstalled/installed again. You can solve those issues using a third party module as features.
Drupal 8 is way more fun and enjoyable. Yes, you are still working with a custom structure enforced by Drupal, and you will need to adhere to certain conventions known as "The Drupal Way". However, you will find many familiar concepts and code syntaxes from other modern PHP projects and frameworks. I have to add, at least for me, this "New Drupal Way" is more easy to understand and makes much more sense.
We're looking forward to continuing to work on many more Drupal 8 projects. If you are wondering how your organization can benefit from Drupal 8, check out our free online training “What Drupal 8 Means for Your Organization” next month, or contact us.