Other notifications

action_event_type

Render the javascript for a custom action event type. The custom event type must be a tuple, for example: <code>{% wire type={live id=myid} action={...} %}</code> Must return {ok, Javascript, Context}

Type:
first

Return:

#action_event_type{} properties:
  • event: tuple
  • trigger_id: string
  • trigger: string
  • postback_js: iolist
  • postback_pickled: string|binary
  • action_js: iolist

activity

An activity in Zotonic. When this is handled as a notification then return a list of patterns matching this activity. These patterns are then used to find interested subscribers.

Type:
map

Return:

#activity{} properties:
  • version: pos_integer
  • posted_time: unknown
  • actor: unknown
  • verb: atom
  • object: unknown
  • target: unknown

activity_send

Push a list of activities via a ‘channel’ (eg ‘email’) to a recipient. The activities are a list of #activity{} records.

Type:
first

Return:

#activity_send{} properties:
  • recipient_id: unknown
  • channel: unknown
  • queue: unknown
  • activities: list

admin_edit_blocks

Used in the admin to fetch the possible blocks for display

Type:
foldl

Return:

#admin_edit_blocks{} properties:
  • id: unknown

admin_menu

Used for fetching the menu in the admin.

Type:
foldl
Return:
list of admin menu items

#admin_menu{} properties: none

Example

By observing this notification, you can add your own menu items to the admin menu. The admin_menu notification is a fold which build up the menu, allowing each callback to add and remove menu items as they wish.

For example, this add a menu separator and an “edit homepage” button to the “content” submenu:

-include_lib("zotonic_core/include/zotonic.hrl").
-include_lib("zotonic_mod_admin/include/admin_menu.hrl").

observe_admin_menu(#admin_menu{}, Acc, _Context) ->
[
    #menu_separator{parent=admin_content},
    #menu_item{
        id=admin_edit_homepage,
        parent=admin_content,
        label="Edit homepage",
        url={admin_edit_rsc, [{id, page_home}]}
    } |Acc
].

The default submenu names are admin_content, admin_structure, admin_modules, admin_auth and admin_system, but you are free to add your own submenus.

admin_rscform

Used in the admin to process a submitted resource form

Type:
first

Return:

#admin_rscform{} properties:
  • id: unknown
  • is_a: unknown

broadcast

Broadcast notification.

Type:
first

Return:

#broadcast{} properties:
  • unknown: unknown
  • unknown: unknown
  • unknown: unknown
  • unknown: unknown
  • unknown: unknown

category_hierarchy_save

Save (and update) the complete category hierarchy (notify)

Type:
first

Return:

#category_hierarchy_save{} properties:
  • tree: unknown

comment_insert

Notification to signal an inserted comment. ‘comment_id’ is the id of the inserted comment, ‘id’ is the id of the resource commented on.

Type:
notify

Return:

#comment_insert{} properties:
  • comment_id: unknown
  • id: unknown

debug

Push some information to the debug page in the user-agent. Will be displayed with io_lib:format(“~p: ~p~n”, [What, Arg]), be careful with escaping information!

Type:
first

Return:

#debug{} properties:
  • what: unknown
  • unknown: unknown

debug_stream

Internal message of mod_development. Start a stream with debug information to the user agent. ‘target’ is the id of the HTML element where the information is inserted. ‘what’ is the kind of debug information being streamed to the user-agent.

Type:
first

Return:

#debug_stream{} properties:
  • target: unknown
  • unknown: unknown

dispatch

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

Type:
first
Return:
{ok, RscId::integer()}, {ok, #dispatch_match{}}, {ok, #dispatch_redirect{}} or undefined
#dispatch{} properties:
  • host: binary
  • path: binary
  • method: binary
  • protocol: union
  • tracer_pid: union

dropbox_file

Handle a new file received in the ‘files/dropbox’ folder of a site. Unhandled files are deleted after a hour.

Type:
first

Return:

#dropbox_file{} properties:
  • filename: unknown

hierarchy_updated

Signal that the hierarchy underneath a resource has been changed by mod_menu

Type:
notify

Return:

#hierarchy_updated{} properties:
  • root_id: binary|integer
  • predicate: atom
  • inserted_ids: list
  • deleted_ids: list

language

Notify that the session’s language has been changed

Type:
notify

Return:

#language{} properties:
  • language: unknown

m_config_update

Site configuration parameter was changed

Type:
notify
Return:
return value is ignored
#m_config_update{} properties:
  • module: atom
  • key: term
  • value: term

m_config_update_prop

Site configuration parameter was changed

Type:
notify
Return:
return value is ignored
#m_config_update_prop{} properties:
  • module: unknown
  • key: unknown
  • prop: unknown
  • value: unknown

mailinglist_mailing

Send a page to a mailinglist (notify) Use {single_test_address, Email} when sending to a specific e-mail address.

Type:
first

Return:

#mailinglist_mailing{} properties:
  • list_id: unknown
  • page_id: unknown

mailinglist_message

Send a welcome or goodbye message to the given recipient. (notify). The recipient is either an e-mail address or a resource id. ‘what’ is send_welcome, send_confirm, send_goobye or silent.

Type:
first

Return:

#mailinglist_message{} properties:
  • what: unknown
  • list_id: unknown
  • recipient: unknown

module_activate

A module has been activated and started. (notify)

Type:
first

Return:

#module_activate{} properties:
  • module: atom
  • pid: pid

module_deactivate

A module has been stopped and deactivated. (notify)

Type:
first

Return:

#module_deactivate{} properties:
  • module: atom

mqtt_subscribe

Subscribe a function to an MQTT topic. The function will be called from a temporary process, and must be of the form: m:f(#emqtt_msg{}, A, Context)

Type:
first

Return:

#mqtt_subscribe{} properties:
  • topic: unknown
  • qos: union
  • mfa: unknown

mqtt_unsubscribe

Unsubscribe a function from an MQTT topic. The MFA _must_ match the one supplied with #mqtt_subscribe{}

Type:
first

Return:

#mqtt_unsubscribe{} properties:
  • topic: unknown
  • mfa: unknown

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 filename on the server.

Type:
first
Return:
#context{} with the result or undefined
#multiupload{} properties:
  • upload: term|string
  • query_args: list

postback_event

Message sent by a user-agent on a postback event. Encapsulates the encoded postback and any additional data. This is handled by z_transport.erl, which will call the correct event/2 functions.

Type:
first

Return:

#postback_event{} properties:
  • postback: unknown
  • trigger: unknown
  • target: unknown
  • triggervalue: unknown
  • data: unknown

postback_notify

Handle a javascript notification from the postback handler. The ‘message’ is the z_msg argument of the request. (first), ‘trigger’ the id of the element which triggered the postback, and ‘target’ the id of the element which should receive possible updates. Note: postback_notify is also used as an event.

Type:
first
Return:
undefined or #context{} with the result of the postback
#postback_notify{} properties:
  • message: unknown
  • trigger: unknown
  • target: unknown
  • data: unknown

sanitize_element

Sanitize an HTML element.

Type:
foldl

Return:

#sanitize_element{} properties:
  • element: tuple
  • stack: list

sanitize_embed_url

Sanitize an embed url. The hostpart is of the format: <<”youtube.com/v...”>>.

Type:
first
Return:
undefined, false or a binary with a acceptable hostpath
#sanitize_embed_url{} properties:
  • hostpath: binary

scomp_script_render

Add extra javascript with the {% script %} tag. (map) Used to let modules inject extra javascript depending on the arguments of the {% script %} tag. Must return an iolist()

Type:
first

Return:

#scomp_script_render{} properties:
  • is_nostartup: boolean
  • args: list

search_query

Handle custom named search queries in your function.

Type:
first
Return:
#search_sql{}, #search_result{} or undefined
#search_query{} properties:
  • search: tuple
  • offsetlimit: tuple

service_authorize

Request API logon

Type:
first

Return:

#service_authorize{} properties:
  • service_module: unknown

ssl_options

Request the SSL certificates for this site. The server_name property contains the hostname used by the client. (first) Returns either ‘undefined’ or a list of ssl options (type ssl:ssl_option())

Type:
first

Return:

#ssl_options{} properties:
  • server_name: binary

tkvstore_delete

Delete a value from the typed key/value store

Type:
first

Return:

#tkvstore_delete{} properties:
  • type: unknown
  • key: unknown

tkvstore_get

Get a value from the typed key/value store

Type:
first

Return:

#tkvstore_get{} properties:
  • type: unknown
  • key: unknown

tkvstore_put

Put a value into the typed key/value store

Type:
first

Return:

#tkvstore_put{} properties:
  • type: unknown
  • key: unknown
  • value: unknown