menu_save
Save the menu tree of a menu resource
user_context
Set #context fields depending on the user and/or the preferences of the user.
acl_logoff
Clear the associated access policy for the context.
mailinglist_mailing
Send a page to a mailinglist (notify)
Use {single_test_address, Email} when sending to a specific e-mail address.
postback_event
Message sent by a user-agent on a postback event. Encapsulates the encoded postback and any
additional data. This is…
identity_verified
Notify that a user’s identity has been verified. Signals to modules
handling identities to mark this identity as…
media_upload_props
Notification that a medium file has been uploaded.
This is the moment to change properties, modify the file etc.
The…
admin_menu
Used for fetching the menu in the admin.
pivot_fields
Foldr to change or add pivot fields for the main pivot table.
The rsc contains all rsc properties for this resource
email_status
Email status notification, sent when the validity of an email recipient changes
page_url
Fetch the url of a resource’s html representation
controller_id
Handle different content representations of a page.
filewatcher
Broadcast some file changed, used for livereload by mod_development
auth_reset
First to check for password reset forms, return undefined, ok, or {error, Reason}.
media_viewer
Request to generate a HTML media viewer for a resource
media_update_done
Media update done notification. action is ‘insert’, ‘update’ or ‘delete’
media_import
Notification to translate or map a file after upload, before insertion into the database
Used in mod_video to queue…
url_abs
Make a generated URL absolute, optionally called after url_rewrite by z_dispatcher
comment_insert
Notification to signal an inserted comment.
‘comment_id’ is the id of the inserted comment, ‘id’ is the id of the…
signup_check
signup_check
Check if the signup can be handled, a fold over all modules.
Fold argument/result is {ok, Props
rsc_insert
Foldr for an resource insert, these are the initial properties and will overrule
the properties in the insert request.
output_html
Fold for mapping non-iolist output to iolist values.
Used when outputting a rendered HTML tree.
Folded accumulator is:…
rsc_get
Resource is read, opportunity to add computed fields
Used in a foldr with the read properties as accumulator.
multiupload
Handle an uploaded file which is part of a multiple file upload from a user-agent.
The upload is a #upload record or a…
sanitize_embed_url
Sanitize an embed url. The hostpart is of the format: <<"youtube.com/v...">> .
email_failed
Notify that we could NOT send an e-mail (there might be a bounce later…)
The Context is the depickled z_email:send/2…
dispatch_host
Try to find the site for the request
Called when the request Host doesn’t match any active site.
postback_notify
Handle a javascript notification from the postback handler. The message is the the request,
trigger the id of the…
export_resource_data
mod_export - fetch a row for the export, can return a list of rows, a binary, and optionally a continuation state.
auth_options_update
Update the given (accumulator) authentication options with the request options.
Note that the request options are from…
auth_precheck
First for logon of user with username, check for ratelimit, blocks etc.
Modules
Modules are the building blocks of Zotonic. They add functionality to your Zotonic website such as:
logon_submit
Handle a user logon. The posted query args are included.
Return:: {ok, UserId} or {error, Reason}
media_upload_rsc_props
Notification that a medium file has been uploaded.
This is the moment to change resource properties, modify the file…
signup_done
Signal that a user has been signed up (map, result is ignored)
media_upload_preprocess
Notification to translate or map a file after upload, before insertion into the database
Used in mod_video to queue…
import_resource
An external feed delivered a resource. First handler can import it.
Return:: {ok, m_rsc:resource_id()} , {error
rsc_update_done
An updated resource has just been persisted. Observe this notification to
execute follow-up actions for a resource…
session_context
Refresh the context or request process for the given request or action
Called for every request that is not anonymous…
search_query
Map a custom search term to a #search_sql_term{} record.
auth_postcheck
First for logon of user with username, called after successful password check.
activity_send
Push a list of activities via a ‘channel’ (eg ‘email’) to a recipient.
The activities are a list of #activity{} records.
rsc_merge
Map to signal merging two resources. Move any information from the loser to the
winner. The loser will be deleted.
ssl_options
Request the SSL certificates for this site. The server_name property contains the hostname used by the client. (first…
content_types_dispatch
Get available content types and their dispatch rules
Example: {“text/html”, page}
A special dispatch rule is ‘page_url’
import_csv_definition
Find an import definition for a CSV file by checking the filename of the to be imported file.
email_received
Notification sent to a site when e-mail for that site is received
identity_verification
Request to send a verification to the user. Return ok or an error.
Handled by mod_signup to send out verification…
dropbox_file
Handle a new file received in the ‘files/dropbox’ folder of a site.
Unhandled files are deleted after a hour.
auth_logoff
User is about to log off. Modify (if needed) the logoff request context.
pivot_rsc_data
Fold over the resource props map to extend/remove data to be pivoted
hierarchy_updated
Signal that the hierarchy underneath a resource has been changed by mod_menu
debug
Push some information to the debug page in the user-agent.
Will be displayed with io_lib:format(“~p: ~p~n”, [What, Arg]…
Browser/server interaction
There are multiple ways to set up interaction between server-side Zotonic code
and client-side JavaScript.
user_is_enabled
Check if a user is enabled. Enabled users are allowed to log in.
Return true , false or undefined . If undefined is…
auth_checked
Fold over the context after logon of user with username, communicates valid or invalid password
menu_rsc
Fetch the menu id belonging to a certain resource
Notifications
This is a list of all built-in notifications that
Zotonic sends. Observe these notifications
in your code to add custom…
custom_pivot
Add custom pivot fields to a resource’s search index (map)
Result is a single tuple or list of tuples {pivotname
signup_confirm
Signal that a user has been confirmed. (map, result is ignored)
export_resource_footer
mod_export - Fetch the footer for the export. Should cleanup the continuation state, if needed.
acl_is_allowed_prop
Check if a user is authorizded to perform an action on a property.
Defaults to true .
email_bounced
Bounced e-mail notification. The recipient is the e-mail that is bouncing. When the
the message_nr is unknown the it…
acl_is_owner
Check if a user is the owner of a resource.
id is the resource id.
mailinglist_message
Send a welcome or goodbye message to the given recipient.
The recipient is either a recipient-id or a recipient props.
auth_validate
First to validate a password. Return {ok, RscId} or {error, Reason}.
request_context
Refresh the context or request process for the given request or action
Called for every request that is not anonymous…
edge_delete
An edge has been deleted
Note that the Context for this notification does not have the user who
deleted the edge.
acl_logon
Initialize context with the access policy for the user.
rsc_upload
Upload and replace the resource with the given data. The data is in the given format.
debug_stream
Internal message of mod_development. Start a stream with debug information to the user agent.
‘target’ is the id of the…
auth_logon
User logs on. Add user-related properties to the logon request context.
Overriding Zotonic
This chapter describes how to override the templates, styling and logic
provided by Zotonic.
edge_update
An edge has been updated
Note that the Context for this notification does not have the user who
updated the edge.
rsc_delete
Resource will be deleted.
This notification is part of the delete transaction, it’s purpose is to clean up
associated…
signup_url
Handle a signup of a user, return the follow on page for after the signup.
Return {ok, Url}
‘props’ is a map with…
email_sent
Notify that we could NOT send an e-mail (there might be a bounce later…)
The Context is the depickled z_email:send/2…
media_replace_file
Notification that a medium file has been changed (notify)
The id is the resource id, medium contains the medium’s…
scomp_script_render
Add extra javascript with the {% script %} tag. (map)
Used to let modules inject extra javascript depending on the…
rsc_query_item
Send a notification that the resource ‘id’ is added to the query query_id.
media_stillimage
See if there is a ‘still’ image preview of a media item. (eg posterframe of a movie)
Return:: {ok, ResourceId} or…
acl_mqtt
MQTT acl check, called via the normal acl notifications.
Actions for these checks: subscribe, publish
dispatch
Final try for dispatch, try to match the request.
Called when the site is known, but no match is found for the path
signup
Request a signup of a new or existing user. Arguments are similar to #signup_url{}
Returns {ok, UserId} or {error
edge_insert
An edge has been inserted.
Note that the Context for this notification does not have the user who
created the edge.
signup_failed_url
Signup failed, give the error page URL. Return {ok, Url} or undefined.
Reason is returned by the signup handler for the…
rsc_update
An updated resource is about to be persisted.
Observe this notification to change the resource properties before they…
url_rewrite
Rewrite a URL after it has been generated using the z_dispatcher
media_import_props
Notification to translate or map a file after upload, before insertion into the database
Used in mod_video to queue…
pivot_update
Pivot just before a m_rsc_update update. Used to pivot fields before the pivot itself.
admin_rscform
Used in the admin to process a submitted resource form
dispatch_rewrite
Rewrite a URL before it will be dispatched using the z_sites_dispatcher
language
Notify that the session’s language has been changed
acl_is_allowed
Check if a user is authorized to perform an operation on a an object
(some resource or module). Observe this…
activity
An activity in Zotonic. When this is handled as a notification then return a list
of patterns matching this activity.
auth_validated
Authentication against some (external or internal) service was validated
email_drop_handler
Drop an e-mail handler for a user/resource id. (notify).
The notification, user and resource should be the same as when…
action_event_type
Render the javascript for a custom action event type.
The custom event type must be a tuple, for example:
{% wire…
postback
Performs a custom server side validation of an input value. This allows you to
add your own validation logic to HTML…
security_headers
Check and possibly modify the http response security headers
All headers are in lowercase.
controller_logon_done
This controller is used as a jumping stone after a log on from the /logon page.
The p argument is passed from the…
media_preview_options
Modify the options for an image preview url or tag. This is called for every
image url generation, except if the…
auth_client_logon_user
Send a request to the client to login a user. The zotonic.auth.worker.js will
send a request to…
url_fetch_options
Determine the URL fetch options for fetching the content of an URL. Used by z_fetch.erl.
media_import_medium
Notification to import a medium record from external source. This is called for non-file
medium records, for example…
resource_headers
Let all modules add resource specific response headers to the request.
The accumulator is the list of headers to be set.
validate_query_args
Called just before validation of all query arguments by z_validation.
This is the moment to filter any illegal…
email_dkim_options
Return the options for the DKIM signature on outgoing emails. Called during
email encoding.
auth_client_switch_user
Send a request to the client to switch users. The zotonic.auth.worker.js will
send a request to…
logon_options
Check for logon options, called if logon_submit returns undefined .
This is used to fetch external (or local…
rsc_import_fetch
Fetch the data for an import of a resource. Returns data in the format
used by m_rsc_export and m_rsc_import. Either…
acl_user_groups_modify
Modify the list of user groups of a user. Called internally
by the ACL modules when fetching the list of user groups a…
media_viewer_consent
Optionally wrap HTML with external content so that it adheres to the cookie/privacy
settings of the current site…
acl_collab_groups_modify
Modify the list of collaboration groups of a user. Called internally
by the ACL modules when fetching the list of…
survey_result_column_values
Modify row with answers for export. The header columns are given and the
values that are known are set in the folded…
survey_result_columns
Add header columns for export. The values are the names of the answers and
the text displayed above the column. The…
translate
Request a translation of a list of strings. The resulting translations must
be in the same order as the request. This…
language_detect
Try to detect the language of a translation. Set is_editable_only to false
to detect any language, even if the language…
auth_identity_types
Return the list of identity types that allow somebody to logon and become an
active user of the system. Defaults to […
email_is_recipient_ok
Check if an email address is safe to send email to. The email address is not blocked
and is not marked as bouncing.