when-not-a-module-for-that/2024-nedcamp-when-not-a-module-make-and-maintain.md

95 lines
2.7 KiB
Markdown

New England Drupal Camp @ Rhode Island College
Providence, RI
November 16, 2024
#NEDCamp2024
9am, Gaige Hall 201
#### When There's Not a Module for That: How to Make (and Maintain) a New Module
benjamin "mlncn" melançon
ben@agaric.coop
---
### Agaric Technology Collective
![The Agaric logo, a blue outline mushroom.](content/images/agaric-icon.png)
presents
Note: my name's ben, i have been a worker and owner at the worker-owned Agaric cooperative since 2006.
---
## When There's *Not*
## a Module for That:
### How to Make (and Maintain)
### a New Drupal Module
---
### Be a part of something bigger
(but not as big as all of Drupal)
#### Commerce
#### Extra Field
#### ECA
#### Search API (and friends)
Note: Build on or with some major —and with luck join a community of
----
##### Example: BEF Links Filter
[drupal.org/project/bef_links_filter](https://www.drupal.org/project/bef_links_filter)
Search API's friends include Facets and Better Exposed Filters
Note: By extending BEF Links module, we were able to get a lot of power— with a much better user experience, thanks to our ~250 lines of code altogether.
----
#### Look for plugin opportunities
Literally, look for plugins,
in `src/Plugin` of whatever modules you are operating in the vicinity of.
BEF Links Filter is a `better_exposed_filters` plugin in about 250 lines of code altogether.
Doing your own or copying
---
### Steal, and keep stealing
----
![A large button with the label "+ Add content block"](images/add-content-block-action-link.png)
Note: If you decide your module should have one of those button links you see at the top right of a bunch of pages in Drupal's administration, you *don't even need to know* that they are called "Action Links" and find a tutorial on making them. You can just go look in the code of a module you know has them, grep for the label, and steal the code around it.
----
![grep -nHIRs "Add content block" web/core/ with a half-dozen results, including web/core/modules/block_content/block_content.links.action.yml:9 and a bunch of results in tests.](images/grep-add-content-block-action-link.png)
Note: Grep. Even when i am fully using an IDE for everything else, i grep in the regular command line when looking for text in a file. This habit is probably fueled more by failing to tell the IDE to index Drupal core and contrib modules more than anything else.
----
!["block_content_add_action:
route_name: block_content.add_page
title: 'Add content block'
appears_on:
- block.admin_library
- entity.block_content.collection
class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction"](images/yml-add-content-block-action-link.png)
---
To be continued…
Note: Let me know what you build!