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.
Theme initialization
The selected UI theme depends on the site.ui_theme configuration. If the config is set to 'user' then the user can select a theme, and if they did not select one then the theme defaults to 'auto'. Any other ui_theme ('auto', 'dark', or 'light') fixes that theme and disables the theme selector in the admin interface.
The common HTML head includes _html_head_theme_init.tpl. This template runs a
small inline script before the main CSS is applied, so pages start with the right
theme and avoid a light/dark flash during rendering.
The template is included from both _html_head.tpl and _html_head_admin.tpl,
so it is applied to normal site pages and admin pages that use the standard
Zotonic head templates.
The script sets two attributes on document.documentElement:
data-zotonic-theme: the selected theme preference, one oflight,darkorauto.data-bs-theme: the resolved Bootstrap theme, eitherlightordark. When the selected preference isauto, this followsprefers-color-scheme: dark.
The selected preference is stored in localStorage under the key
zotonic-theme. The stored value is JSON encoded, for example "dark", so it
can also be read and written through Cotonic model/localStorage. If the value is
missing, invalid JSON, or not a supported theme, templates and client-side code
fall back to auto.
CAFS configuration
The base module lists the core content-addressable file storage settings in the
admin configuration catalog. These are per-site m_config settings in the site
namespace; they do not require mod_filestore or a separate CAFS module.
| Key | Default | Description |
|---|---|---|
site.cafs_preview_retention_days | 90 | Grace period for obsolete previews, in days. Valid values are 1 through 3650; invalid values use 90. Cleanup is lazy, and other valid usages preserve shared output. Requests do not extend the grace period. |
site.cafs_renderer_version | 1 | Additional image renderer version. Change after rendering changes not already captured in the generation key, then call z_file_sup:refresh/0 to invalidate running file entries. New previews are generated on demand. |
See model#m_cafs for source recovery retention, shared preview collection, and
remote storage behavior.
Accepted Events
This module handles the following notifier callbacks:
observe_content_types_dispatch: Add an extra content-type to the 'id' controller usingcontroller_api:content_types_provided.observe_dispatch: Check if there is a controller or template matching the path usingz_url:url_path_encode.observe_edge_delete: If an edge is deleted, then force a repivot of the subject usingz_pivot_rsc:insert_queue.observe_edge_insert: If an edge is inserted, then force a repivot of the subject usingz_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 usingz_media_preview:can_generate_preview.