When There's Not a Module for That: How to Make (and Maintain) a New Module
benjamin melançon
Chris Thompson
You've built sites with Drupal and know that with a few dozen modules (and a ton of configuring), you can do nearly everything in modern Drupal.
But what do you do when there's not a module for that? When the modules that exist don't meet your needs, and cannot be made to by contributing changes?
You make your own.
This session will help you take that step. All you need to do is write two text files. The first file tells Drupal about the module; it’s not code. The second file can have as little as three lines of code in it. Making a module is something that anyone can do. There are many (mostly simple) rules to follow and tons of tools to use—and lots of exploration to do. Every person developing a module is still learning.
Learning Objectives
In this session, you will:
* Learn how to decide when to make your own module.
* Write a module that plays well with Drupal core and other modules.
* Discover ways to explore the options for extending and overriding functionality provided by Drupal core and other modules.
Target Audience
People who have done some site building and run into limitations, or who simply want to try out developing with code.
Prerequisites
The only prerequsite is having done some site building with Drupal, and so having familiarity with Drupal configuration and its limits. Information gained will be equally relevant to any version of modern Drupal (8 through 10 and onward).
***
Draft (updates needed) presentation outline:
Part 1: Looking for modules - is there already a module for that? 5 minutes
Part 2: Contributing to an existing module - is there *almost* a module for that? 10 minutes
Part 3: Starting a new module - 25 minutes
- Considerations for writing a new module
- What tools are available?
Part 2: Contributing to an existing
* Add a feature, a "Mail" option to Social Simple: https://www.drupal.org/project/social_simple/issues/2899517
* Fix bugs, possible example https://www.drupal.org/project/comment_notify or https://www.drupal.org/project/tzfield/issues/2904016
* Upgrade to modern Drupal, possible example https://www.drupal.org/project/flatcomments
Part 3:
* A "one line" module (alter hook)
* A plugin module ("modern Drupal hooks")
* A module that was generated https://www.drupal.org/project/ckeditor_youtube/ - simple and used by many, and slowly got more complex
* A module bringing in a PHP library and getting crazy (started with simple field formatter, can use this or another module to demo that) - https://drupal.org/project/inotherwords
Additional Details:
- Audience level: Intermediate
- Topic: Developer
- Room: Gaige Hall 206