mod_base

mod_base is the base module, which acts as a container module holding most of Zotonic basic dispatch rules, Actions and Module tags.

Note that the amount of templates has been kept to a minimum in this module, so that sites are free to implement whatever templates they want. Core base module providing fundamental dispatch rules, actions, and template components used across sites.

Accepted Events

This module handles the following notifier callbacks:

  • observe_content_types_dispatch: Add an extra content-type to the 'id' controller using controller_api:content_types_provided.
  • observe_dispatch: Check if there is a controller or template matching the path using z_url:url_path_encode.
  • observe_edge_delete: If an edge is deleted, then force a repivot of the subject using z_pivot_rsc:insert_queue.
  • observe_edge_insert: If an edge is inserted, then force a repivot of the subject using z_pivot_rsc:insert_queue.
  • observe_hierarchy_updated: Renumber category ranges after hierarchy edits so tree lookups remain consistent.
  • observe_media_stillimage: Return the filename of a still image to be used for image tags using z_media_preview:can_generate_preview.

Edit on GitHub

Observes

Notifications

observe_content_types_dispatch/3

Get available content types and their dispatch rules Example: {{<<”text”>>, <<”html”>>, []}, page} A special dispatch rule is ‘page_url’, which refers to the…

Notifications

observe_edge_delete/2

An edge has been deleted Note that the Context for this notification does not have the user who deleted the edge.

Notifications

observe_dispatch/2

Final try for dispatch, try to match the request. Called when the site is known, but no match is found for the path

Notifications

observe_media_stillimage/2

See if there is a ‘still’ image preview of a media item. (eg posterframe of a movie) Return:: {ok, ResourceId} or undefined

Notifications

observe_edge_insert/2

An edge has been inserted. Note that the Context for this notification does not have the user who created the edge.

Models

Models

mqtt_ticket

A ticketing system for out of band MQTT posts via HTTP.

Controllers

Controllers

controller_api

controler_api processes authorized REST API requests: It provides an easy way to create API calls to allow computer programs to perform functions on your…

Controllers

controller_file

Serve an uploaded-, resized- or library file.

Controllers

controller_id

Handle different content representations of a page.

Controllers

controller_ping

Simple controller for connection tests, used on the /test/connection page.

Dispatch rules

Dispatch rules

mod_base dispatch rules

URL dispatch rules defined by mod_base in apps/zotonic_mod_base/priv/dispatch/dispatch.

Filters

Filters

add_day

Adds a day to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

Filters

add_hour

Adds an hour to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

Filters

add_month

Adds a month to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

Filters

add_week

Adds a week to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

Filters

add_year

Adds a year to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

Filters

after

Return the first element after another element in a list. For example:

Filters

append

Appends the argument to the value.

Filters

as_atom

Convert a value to an Erlang atom.

Filters

before

Return the first element before another element in a list. For example:

Filters

brlinebreaks

Translate HTML <br/> elements into ASCII newlines ( \n ).

Filters

capfirst

Converts the first character of the value to uppercase.

Filters

center

Centers the value in a field of a certain width using spaces.

Filters

chunk

This filter splits a list in shorter lists. It splits an array in sub-arrays of at most a given length. This is useful when displaying a list of items in…

Filters

content_type_label

Return a translated, human-readable label for a MIME content type.

Filters

content_type_urls

Return the available content representations and URLs for a resource.

Filters

date

Formats a date or datetime according to the format specified in the argument.

Filters

datediff

Calculate the difference between two dates, returning a single part of that difference.

Filters

default

Provide an alternative value in case a value has a falsy value (0, false , undefined or empty string).

Filters

default_if_none

Provide an alternative value in case a value is undefined.

Scomp

Scomp

chart

Render a chart without JavaScript, CSS, external services, or external assets.

Scomp

chart_donut

Render a donut chart as inline SVG.

Scomp

chart_pie

Render a pie chart as inline SVG.

Scomp

chart_pie3d

Deprecated compatibility alias for chart_pie.

Scomp

debug

Shows which variables are assigned for use in the current template’s scope:

Scomp

lazy

Custom tag which adds a ‘loader’ image to the page and performs a one-time action when loader comes into view.

Scomp

loremipsum

Inserts a piece of “lorem ipsum” text into the page.

Scomp

pager

Show a pager for search results.

Scomp

spinner

Add an AJAX activity indicator.

Scomp

tabs

Make a HTML element into a tab set.

Scomp

worker

Start a named Cotonic worker from a template.

Validators

Validators

acceptance

Check if an input value evaluates to true.

Validators

custom

Support for custom client-side (JavaScript-based) validators.

Validators

date

Validate input date against a given date format.

Validators

email

Check if the content of the input field is an e-mail address.

Validators

format

Regular expression test.

Validators

json

Validate that a form value is JSON.

Validators

length

Check the length of a text input.

Validators

name_unique

A validator to check whether a resource’s name is unique:

Validators

page_path_unique

A validator to check whether a resource’s page path is unique:

Validators

postback

Performs a custom server side validation of an input value. This allows you to add your own validation logic to HTML form fields.

Validators

presence

Check if an input has been filled in or checked.

See also

Modules

mod_custom_redirect

Enables redirects from unknown hosts and paths to other locations. The other location can be a known path or another web site.

Developer guide

Dispatch rules

Dispatch rules route incoming requests to controllers.

Referred by

Modules

mod_custom_redirect

Enables redirects from unknown hosts and paths to other locations. The other location can be a known path or another web site.

Developer guide

Controllers

Controllers are the Erlang modules which decide what happens when a browser requests a page. Zotonic looks at the dispatch rules that match the requested URL

Developer guide

Dispatch rules

Dispatch rules route incoming requests to controllers.