Module Development

Guiding Scenario for Drupal 8, 9, and 10

We'll be working with the Anytown Farmers Market site, which we built in the Drupal User Guide. Our goal is to extend and enhance this site using custom modules, to fulfill project-specific requirements. We use a narrative approach, which we hope will help you better understand the real-world applications of module development in Drupal.

Goal

Explain the guiding scenario which ties together all the code examples in this guide, and provides a project-based learning approach to Drupal module development.

Prerequisites

  • You're familiar with the Anytown Farmers Market site that we covered in the Drupal User Guide.
  • You're familiar with the Drupal site building and administrative tasks and concepts taught in the Drupal User Guide.

The guiding scenario

You are a developer tasked with adding new features to the Anytown Farmers Market site. You can't add the features with Drupal's site building tools or any existing contributed modules, so you'll need to write some custom code. You're familiar with PHP, and web development using a CMS or framework, but this is your first time writing custom code for Drupal.

You need to add the features below.

Weather forecast feature

A new page at the URL, /weather, that shows the current weather forecast and details about any weather-related happenings for the next market weekend market. For example, an ice skating rink that's open in the winter or a market closure due to icy conditions. You'll need to retrieve the forecast using a remote API, and a site administrator should be able to fill out a form to publish current weather-related happenings.

Vendor attendance feature

A feature that enables vendors to say that they plan to attend the upcoming market and who the contact person is. While we could update this information through the vendor node edit form, we want a simplified UI, since we're asking vendors to do this every week.

As you read through the guide and try out the described tasks, you may choose to follow the scenario as-is, or customize the tasks to suit another purpose.

Let's get started.

Recap

We introduced the guiding scenario and project requirements which we'll fulfill in this guide.

Further your understanding

  • Can you write user stories that outline the work you'll be doing for this project?

Additional resources

Drupal Module Developer Guide