Text

All Text

How to customise error pages

Specific error pages Zotonic’s controller_http_error first tries to find an error page template that is specific for…

Logging to Logstash

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

Icons in templates

Zotonic provides a couple of ways to show icons in templates:

Execute tasks asynchronously using the task queue

The Zotonic task queue lets applications perform tasks asynchronously.

Overriding Zotonic

This chapter describes how to override the templates, styling and logic provided by Zotonic.

Custom search

Implement a custom search by observing the search_query notification in your module. Imagine you want to search cookies…

Create a custom tag

Custom tags, internally called scomps , are module-defined tags, which are used when the logic is too complex to be…

Create a custom model

In this chapter we will look at how to implement a model around the The Open Movie Database (OMDB) API.

Create a custom filter

Create custom template filters to change the way variables are rendered in your templates. By following some simple…

Cookbooks

Admin cookbook Creating a custom widget on the edit page Customizing the layout of the admin edit page Customizing the…

jquery_effect

Trigger various jQuery effects on the target element. Mostly, each of these effects have their own action as a shortcut

m_auth2fa

Not yet documented.

striptags

Removes all HTML tags from the value.

controller_id

Handle different content representations of a page.

filter

Filters a list on the value of a property, either on presence or equality.

is_not_a

is_not_a mirrors is_a. It is particularly useful when iterating over a category and excluding members of a sub-category…

is_a

Filter a list of resource ids on category, or test if a single resource id belongs to a category.

is_visible

Filter a list of resource ids so that only the visible ids remain.

pprint

Pretty print a zotonic value in a template.

Release 0.37.0

Welcome to Zotonic 0.37.0, released on 5 March, 2018.

replace

Regular expression replacement of a pattern with a string.

match

Match a value with a regular expression.

Regular Expressions

match replace

controller_file_id

Redirect to the controller controller_file.

controller_file

Serve an uploaded-, resized- or library file.

Release 0.57.0

Welcome to Zotonic 0.57.0, released on May 11, 2020.

Storing date/time fields

Some interesting tidbits about saving/updating a date/time field of a resource.

E-mail handling

Any Zotonic system is capable of sending and receiving e-mail messages over SMTP.

minmax

Force the given value in the given range.

min

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

max

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

page_url

Fetch the url of a resource’s html representation

Command-line

The zotonic command runs a number of utility commands which all operate on a Zotonic instance.

Testing sites

It is possible to create end-to-end integration tests for Zotonic websites. Tests like these are called sitetests .

is_number

Test if a value is a number (integer or floating point):

Erlang tab completion

Get quicker access to Zotonic code on the shell.

controller_admin_edit

The main admin edit controller. This controller serves the edit page where resources can be edited.

controller_admin_media_preview

A controller for rendering preview thumbnails of any media embedded in a richtext-editor component of a resource on the…

Dispatch rules

Dispatch rules route incoming requests to controllers.

Controllers

Controllers are the Erlang modules which decide what happens when a browser requests a page. Zotonic looks at the…

Wires

Wires are the older way to code actions and client/server interaction. It is now advised to use MQTT topics with…

Filter and convert characters

Applying Erlang Binary syntax to get fast character manipulation.

controller_template

Show a template.

Access control

Access control is about defining who is allowed to access certain resources. It takes two steps:

mod_seo

Adds basic search engine optimization to the base templates and provides an admin interface for configuring SEO options…

controller_page

Show a rsc as a HTML page.

media_identify_file

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

disable

Sets the “disabled” attribute of a HTML tag and adds the CSS class “disabled”.

enable

Resets the “disabled” attribute of a HTML tag and removes the CSS class “disabled”.

Installation requirements

Zotonic runs on Linux, Mac OS X and (not officially) on Windows.

Troubleshooting

Installation Zotonic won’t start and shows errors when running zotonic debug Check your site’s database configuration.

The Status site

The Zotonic “status” site is the first thing you see once you have installed Zotonic, or if you do not have any sites…

Sites

Zotonic has the capability of serving more than one site at a time. You can have multiple sites enabled, each with its…

Getting Started

You have three options for running Zotonic: to get started quickly, start our Zotonic container. You can also use Nix…

toggle_class

Toggle a CSS class from an HTML element.

add_class

Add a css class to an html element.

remove_class

Remove a CSS class from an HTML element.

m_backup

Not yet documented.

mod_backup

mod_backup serves two different purposes: it makes a nightly backup of your files and database, and can also backup…

email_status

Email status notification, sent when the validity of an email recipient changes

pivot_fields

Foldr to change or add pivot fields for the main pivot table. The rsc contains all rsc properties for this resource

slide_fade_out

Hide an element by animating the height and opacity.

slide_fade_in

Show an element by animating the height and opacity.

slide_up

Hide an element by animating the height.

slide_down

Show an element by animating the height.

fade_out

Hide an element by animating the opacity.

hide

Hide an element without any animation.

show

Show an element without any animation.

toggle

Toggle the visibility of an element.

fade_in

Show an element by animating the opacity.

utc

Translates a datetime from local time to UTC.

timesince

Show a readable version of a date/time difference.

sub_year

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

sub_week

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

sub_month

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

sub_day

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

ne_day

Tests if two dates are not equal.

in_past

Tests if a date is in the past.

in_future

Tests if a date is in the future.

eq_day

Tests if the value is a date and equal to the argument. The value and the argument must be a tuple of the format {Y,M

datediff

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

date_range

Show a date range.

add_year

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

add_week

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

add_month

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

add_day

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

Dates

add_hour add_day add_month add_week add_year date date_range datediff eq_day in_future in_past ne_day sub_hour sub_day…

summary

Extract a summary from a resource.

mod_admin_merge

Adds functonality to merge two pages together into a single page.

dispatch

Dispatch rules Name Path Resource Args admin_merge_rsc [“admin”,”merge”,id] controller_admin_edit [{template

confirm

Show a JavaScript confirm message and on confirmation triggers one or more actions and/or sends a postback to the…

alert

Show an alert dialog.

Notifications

alert confirm growl

zmedia_choose

Used after a media item is selected in the media chooser for the TinyMCE editor.

Port configurations

Port configurations can be tricky, especially in combination with SSL. Here we explain all steps to come to a correctly…

Useful environment variables

The following environment variables influence how Zotonic starts up.

mod_l10n

Localization of Zotonic. Provides lookups for country, month, week names.

dispatch

Dispatch rules Name Path Resource Args admin_l10n [“admin”,”localization”] controller_admin [{template,”admin_l10n.