Site Building

2.4. Concept: Modular Content for Drupal 8, 9, and 10

What is modular content?

Given that the content of your site is stored in a database, it is desirable to make the content modular, meaning that certain pages on your site, rather than being edited as a whole page, are instead generated automatically from other content items. For instance, in the farmers market site scenario, you might create individual content items for recipes. If the recipe content items have a field that keeps track of ingredients, then your site could include a composite page that would list recipes, and allow visitors to search for a recipe that contained some particular ingredient they had bought at the market.

Smaller sections of pages can also be generated as composites. For instance, recipe content items could have a field that keeps track of which vendor submitted the recipe (see Section 6.4, “Concept: Reference Fields”), with the vendor details edited in separate vendor content items. This would allow you to do the following on your site:

  • On each Recipe page, there could be an area that displays some information about the vendor that submitted the recipe, such as their name and market stall number.
  • Each vendor page could have a section that lists the recipes they have submitted.

The key idea is that each piece of information is only edited in one place. When vendor information is updated, all recipe pages that display that vendor information are automatically updated; when a recipe is submitted by a vendor, it is automatically displayed on the vendor page. The core Views module is the usual way to use modular content to create composite pages and page sections; see Section 9.1, “Concept: Uses of Views” for more information. Also, view modes are useful for defining different ways to display each content item; see Section 6.10, “Concept: View Modes and Formatters” for more information.

Drupal User Guide