Skip to main content

Main navigation

  • Tips & Tutorials
  • About the Options
    • Building with Drupal Canvas and Jarvis
    • Request the StarterSite
    • Spin Up A Blank Drupal Site
    • Case Studies
    • Demo
  • Support
    • I'm Rod Martin
    • Contact Us
  • Training
    • Drupal in a Day Training
    • Drupal Site Building Advanced Training
    • Drupal Immersion Training
    • Custom Content Editor Training
    • Drupal AI Training
  • YouTube
    • Introduction to Drupal AI
  • Search
Home

Exploring AI-Generated Modules in Drupal: A Real-World Test

drupal ai custom modules
Filed Under
AI
Publication Date
Tuesday, October 29th, 2024

Exploring AI-Generated Modules in Drupal: A Real-World Test

As AI technology advances, many wonder, “Can AI actually generate a Drupal module that works?” I’m going to share my experience using ChatGPT to generate functional Drupal modules for a real project. (Video below)

AI and Drupal Development: Why I’m Excited

With AI tools improving daily, especially with applications in Drupal, I decided to test whether ChatGPT could build a couple of custom modules for me. One of these modules needed to be straightforward, while the other had a slightly more complex function.

Module 1: The Custom “FPS” Module

For the first test, I requested a module that would allow users with specific roles (e.g., “User” or higher) to change the default homepage without accessing a menu. The users needed to select from several pre-set options, such as “Dashboard,” “Dashboard Fall,” and “Dashboard January.”

The module’s purpose was to let a tax consulting website swap homepages throughout the year, highlighting different information during key seasons like January.

Here’s the prompt I provided to ChatGPT:

“You are a senior Drupal developer with five years of Drupal 10 experience. Create a custom module called FPS that allows a user with the role of User or higher to update the default front page without accessing a menu. They should be able to choose from the following options: Dashboard, Dashboard Fall, and Dashboard January.”


What ChatGPT Delivered

ChatGPT generated an FPS module that included:

1. Info file – Essential details for Drupal to recognize the module.

2. Routing file – Defining paths for page navigation.

3. Permissions file – Controlling access for authorized roles.

4. Controller – The “FrontPageSwitcherController” class to handle the page-switching logic.

5. Form class – “FrontPageSwitcherForm” to present the dashboard options to the user.

The module structure was well thought out, with separate files for each key function. Here’s what the module looked like in action:

• I added a button at the bottom of the homepage, allowing users to select a dashboard.

• On selecting a dashboard, it redirected users to the corresponding path.

• The homepage content updated based on the choice.

With this setup, users could select a dashboard without having to deal with layout configuration themselves. ChatGPT also provided a helpful summary with installation instructions, which simplified testing and deployment.

Module 2: Custom Taxonomy Title

In the next test, I needed to modify the page title on the taxonomy term pages. By default, Drupal displays “Add term” on these pages, but I wanted it to show “Add [Vocabulary Name].”

In previous Drupal versions, this could be achieved using a simple hook. However, in Drupal 10, that hook was deprecated. I asked ChatGPT to handle this requirement.

Here’s the prompt:

You are a senior Drupal 10 developer. Create a custom module for Drupal 10 to change the text "Add Term" at the the top of Add Term page. Replace the words "Add Term" with "Add" and the name of the vocabulary the term is being added to.

What ChatGPT Generated

ChatGPT created a new module called “Custom Taxonomy Title,” which consisted of:

• Service file – A custom service to manage the title-changing logic.

• Route subscriber – To override default routes and connect to the custom controller.

• Controller – Fetches the taxonomy vocabulary and applies the appropriate title.

Initially, ChatGPT attempted to use the outdated hook. But after feedback, it revised the code to use the new route subscriber method.

Observations and Takeaways

Both modules worked seamlessly and demonstrated ChatGPT’s capability to produce functional, well-structured Drupal modules with minimal guidance. As a trainer and developer, I was pretty happy that I didn’t need to spend time creating the modules.  However, there’s no way I could have done the troubleshooting necessary without knowing module development.  Bottom line - it’s a huge time saver but it still isn’t going to replace anyone right now.

A Word for Junior Developers

AI’s growing capabilities mean that it’s starting to handle many tasks typically assigned to junior developers. Simple modules like these, once used for gaining experience, can now be generated by AI in minutes. For emerging developers, this underscores the need to continuously refine your skills and focus on complex, value-driven projects.

 

Latest Tips

  • Speaking at Drupal Camp Chattanooga
  • How Long Does It Take to Move a Layout Builder Site to Drupal Canvas? I Timed My Own.
  • Your AI API Keys Belong in the Key Module: Drupal AI Setup in 60 Seconds
  • Three AI Projects That Actually Paid for Themselves
  • Build a Single Directory Component From Scratch, Then Drop It Into Drupal Canvas (Full Walkthrough)
  • Drupal AI Training at Drupal GovCon - August 2026
  • Drupal's Site-Building Direction Isn't Settled Yet. Here's How to Build Anyway.
  • I Built a Daily Content Delivery System. Drupal is the Glue. Claude Connects the Pieces
  • AI for Small Drupal Sites: A Practical Guide for Site Builders in 2026
  • How Claude Is Automating My Weekly Life: Three GitHub Repos as Exhibits

Request the Starter Site
Schedule a Consultation
Share on Facebook (opens in new tab) Share on X (opens in new tab) Share on LinkedIn (opens in new tab) Share by email

Copyright 2026 DrupalHelps.com | Rod Martin

Drupal is a registered trademark of Dries Buytaert.