In this section

  1. 1Create a reusable moduleCreate apps_user/zotonic_mod_garden with the following files. This example adds a discoverable module without starting an extra process.
  2. 2Choose a model, controller, observer, or componentChoose a model, controller, observer, or component.
  3. 3Expose data through a modelCreate src/models/m_garden.erl in the Garden module. This complete example exposes a public greeting:
  4. 4Add an HTTP controllerUse controller_template when a dispatch rule only needs to render a template. Write a custom controller when the endpoint needs additional request processing or response behavior.
  5. 5Respond to a notificationFind the notification definition and inspect its callers before implementing an observer. The notifier operation determines whether observers collect results, stop at a first result, or fold a value.
  6. 6Add a filter or rendering componentUse a filter for a small transformation of an input value. Keep missing and unexpected values predictable, and escape output at the point where it becomes HTML.
  7. 7Upgrade a module's data schemaVersion schema changes through the module's installation and upgrade mechanism. Inspect a module using -mod_schema and manage_schema/2 before adding your own versioned step.
  8. 8Run work outside a requestUse an existing Zotonic task mechanism when it fits the job. Use a supervised worker when the work needs a persistent process with its own lifecycle.