drupal

Topics related to drupal:

Getting started with drupal

Drupal is an open-source content management system built in PHP. Drupal is designed to be flexible and powerful allowing developers to build a wide variety of sites, from blogs and brochure-style sites to complex e-commerce platforms. Through it's community driven modular architecture Drupal is able to provide tools to extend the core functions to help speed development of large and complex projects.

Currently there are two supported versions of Drupal: 7 and 8. Drupal 8 is built on components from the Symfony framework and many other third party libraries to provide modern development structures.

Drush

What is Drush?

Drush is a command-line scripting interface for Drupal sites. It allows for command-line management of Drupal sites.

Module development - Drupal 7

Examples for developers module should be used as a reference for module development ideally. It has explanation of all the major APIs, well documented usage. It is all in for begineers to understand module development.

Theme development - Drupal 7

Example for Drupal 8 Queue API and the Batch API

Field Formatter

Some things are important to consider when implementing a Field Formatter.

The implementation of your formatter must be inside your module in the folder src/Plugin/Field/FieldFormatter. The annotations are also critical as they identify your module and which field types it's applicable to.

In this example, this formatter is applicable only to fields of the type email. You can apply your formatter to a number of fields if necessary. If your formatter would, for whatever reason, be applicable to email and date fields:

field_type = {
  "email",
  "date",
}

One pitfall I've faced when first implementing field formatters with settings is that the settings weren't saved when changed. There is no explicit save method and the solution is to implement the defaultSettings() method and specify the field names that make up your configuration form. Also don't forget to set the #default_value in the settingsForm method.

If you want to have a specific TWIG template for your formatter it's as simple as configuring a #theme key while building the render array in the viewElements method then in your .module file implement hook_theme

function obfuscator_field_formatter_theme() {
  return [
    'obfuscator_field_formatter' => [
      'variables' => array('title' => NULL, 'url' => NULL),
      'template' => 'obfuscator-field-formatter'
    ],
  ];
}

Then create the templates folder in the root of your module and have a file named obfuscator-field-formatter.twig.html where you output the markup you need. In this example the variables the from the render #title and #url will be available.

Twig

The Rules module

Resources

  • Video tutorials: Johan Falk did an amazing job in the early Drupal 7 days by creating an impressive set of tutorials to "Learn the Rules Framework" with a set of over 30 videos and related blogposts hosted at nodeone.se (license = Attribution-Noncommercial-Share Alike 3.0).

    However the nodeone.se domain is no longer hosting them. Learn Rules is an attempt to recover these valuable blogposts (with related links to the corresponding videos).

  • The Tiny Book of Rules is a (15 pages) jumpstart about the Rules module.

The Views module

Drupal cache and performace

Drupal 8 Entity API