Documentation

All Documentation

Just enough…

These Cookbook items each represent a stage in some Zotonic users’ journeys to understand the workings of Erlang and…

Just enough Erlang/OTP and rebar, part 1

Zotonic source code have you scratching your head? Learn Rebar first.

Just enough Erlang/OTP and rebar, part 2

Building a gen_server to front the library and generating documentation.

Just enough Erlang shell

An indispensible tool for both learning and programming Erlang.

Just enough Postgres

Understand the primary data-store of Zotonic.

Just Enough Regular Expressions (in Erlang)

Learn how to manipulate string data with the re module.

language

Notify that the session’s language has been changed

language

Return the language the resource (or translated text) will be displayed in.

language_detect

Try to detect the language of a translation. Set is_editable_only to false to detect any language, even if the language…

language_dir

Return rtl or ltr depening on the direction of the language.

language_sort

Sort a list of language codes or map with languages on their name. Return a list of {Code, LanguageProps} pairs.

last

Returns the last character or element.

lazy

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

length

Returns the length of the value.

length

Check the length of a text input.

lib

Combine css and javascript includes in a single request.

linebreaksbr

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

link

Add an edge between two resources. Used in the admin.

Lists

after before chunk exclude filter first flatten_value group_by index_of is_list join last length make_list member…

live

Live updating templates connected to MQTT topics.

ljust

Justifies the value in a field of a certain width to the left, with spaces.

load

Loads the given custom tags for use in the templates. Normally not needed, as custom tags are automatically loaded…

log_format_stack

Escapes and formats a Javascript string with a stack trace to readable HTML.

Logging

Zotonic uses Logger for logging. Logger metadata is automatically set by Zotonic in the controller functions.

Logging to Logstash

Logstash is often used for log centralization and analysis. This cookbook describes how to set up Zotonic for logging…

logoff

This action logs off the current user and reloads the current page as the anonymous visitor.

logon_options

Check for logon options, called if logon_submit returns undefined . This is used to fetch external (or local…

logon_ready_page

Check where to go after a user logs on.

logon_submit

Handle a user logon. The posted query args are included. Return:: {ok, UserId} or {error, Reason}

loremipsum

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

lower

Translates the value to lower case.

m_acl

The m_acl model gives access the id of the currently logged in user, and provides a mechanism to do basic access…

m_acl_rule

Not yet documented.

m_acl_user_group

Not yet documented.

m_admin

This model exposes some meta-information for the use in mod_admin templates.

m_admin_blocks

Not yet documented.

m_admin_config

Not yet documented.

m_admin_identity

Not yet documented.

m_admin_menu

This model holds the admin menu, which is built up by calling each module to add items to the menu.

m_admin_note

Add an editorial note to any resource.

m_admin_status

Not yet documented.

Mailing list

dialog_mail_page dialog_mailing_page mailing_page_test mailinglist_confirm mailinglist_unsubscribe

Mailing list

inject_recipientdetails mailinglist_recipient_key_decode

mailinglist_confirm

Confirm a mailinglist subscription. Required argument is the confirm_key .

mailinglist_mailing

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

mailinglist_message

Send a welcome or goodbye message to the given recipient. The recipient is either a recipient-id or a recipient props.

mailinglist_recipient_key_decode

Used on the mailing list subscriptions page where users and recipients can unsubscribe from mailinglists.

mailinglist_subscribe

Show the mailinglist subscription form to subscribe to a certain mailinglist id.

mailinglist_unsubscribe

Cancel a mailing list subscription. The recipient id is given with the id argument.

mailing_page_test

Post a message to the test mailing list, given with the id argument.

make_list

Forces the value to a list.

Managing redirection after login and signup

Configure mod_signup to redirect to something other than a member’s home page.

mask

Places a mask over an element, useful for blocking user interaction during lengthy postbacks.

mask_progress

Sets the progress bar of a mask.

match

Match a value with a regular expression.

m_auth2fa

Not yet documented.

m_authentication

Not yet documented.

max

Take the maximum of the filter value and its first argument.

m_backup

Not yet documented.

m_backup_revision

Not yet documented.

m_category

This model can retrieve information about the resource category hierarchy in different ways.

m_client_local_storage

Model to access the localStorage on the client (browser).

m_client_session_storage

Model to access the sessionStorage on the client (browser).

m_comment

Accesses comments on a page.

m_config

Zotonic has two places where a site’s configuration is kept:

m_config_update

Site configuration parameter was changed

m_config_update_prop

Site configuration parameter was changed

m_content_group

Not yet documented.

m_copyright

Not yet documented.

m_custom_redirect

Not yet documented.

md5

Translates a string to a md5 hex value.

m_development

Not yet documented.

m_edge

Access information about page connections.

Media

Resources can have media resources attached to them. Resources and their media (images, video and audio) are connected…

media

Show embed, video or audio media.

Media Best Practices

Use Media classes to define image properties.

media_for_language

Filter a list of media items by their medium_language property, return the best matching with the current or given…

media_identify_extension

Try to find a filename extension for a mime type (example: <<".jpg">> )

media_identify_file

Try to identify a file, returning a map with file properties.

media_import

Notification to translate or map a file after upload, before insertion into the database Used in mod_video to queue…

media_import_medium

Notification to import a medium record from external source. This is called for non-file medium records, for example…

media_import_props

Notification to translate or map a file after upload, before insertion into the database Used in mod_video to queue…

Media notifications

media_identify_extension media_identify_file media_import media_import_medium media_preview_options media_import_props…

media_preview_options

Modify the options for an image preview url or tag. This is called for every image url generation, except if the…

media_replace_file

Notification that a medium file has been changed (notify) The id is the resource id, medium contains the medium’s…

media_stillimage

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

media_update_done

Media update done notification. action is ‘insert’, ‘update’ or ‘delete’

media_upload_preprocess

Notification to translate or map a file after upload, before insertion into the database Used in mod_video to queue…

media_upload_props

Notification that a medium file has been uploaded. This is the moment to change properties, modify the file etc. The…

media_upload_rsc_props

Notification that a medium file has been uploaded. This is the moment to change resource properties, modify the file…

media_viewer

Request to generate a HTML media viewer for a resource. The HTML data can not contain any Javascript, as it might be…

media_viewer_consent

Optionally wrap HTML with external content so that it adheres to the cookie/privacy settings of the current site…

m_editor_tinymce

Not yet documented.

m_email_dkim

DomainKeys Identified Mail Signatures (RFC 6376) is a method to add a signature to outgoing emails. This enables…

m_email_receive_recipient

Not yet documented.

m_email_relay

Not yet documented.

m_email_status

Tracks the send/bounce/error status of all outgoing emails.

member

Finds a value in a list.