Global template variables

These variables are always available for rendering in templates.

zotonic_version

The version of Zotonic, for example "1.0-dev".

zotonic_dispatch

An atom with the name of the dispatch rule that was applied to render the current page.

zotonic_dispatch_path

A list containing the request path used as initial input for the dispatcher. The path is split on / and after an optional rewrite. This means that the list doesn’t contain the language prefix. For example, the path /en/foo/bar?a=b will give the list [<<"foo">>, <<"bar">>].

zotonic_dispatch_path_rewrite

Same as zotonic_dispatch_path, but set to the path after an optional internal request rewrite inside the dispatcher. For example if a resource has its page_path set to /foo and the requested path is /en/foo then the zotonic_dispatch_path will be set to [<<"foo">>] and the zotonic_dispatch_path_rewrite could be set to something like [<<"page">>, <<"1234">>, <<"foo-slug">>].

z_language

The currently selected language. This an atom, for example: en.

q

A key/value list containing the current request’s query variables. For GET requests, these are the arguments passed from the query string (e.g. ?foo=bar); for POST requests, these are also the values posted in the POST form. For more access to the raw request data, look at the m_req model.

now

The UTC date and time in Erlang tuple notation, for instance {{2014,4,17},{13,50,2}}.

m

m is not really a value, but it’s an indicator to trigger a lookup in one of Zotonic’s Models. For instance the m_rsc model is always exposed and can be used like this {{ m.rsc[123].title }}.

true, false, and undefined

The values true, false and undefined are predefined.

Edit on GitHub

Tags Reference Models

Referred by

url

Generate the URL for a named dispatch rule. In this way it is possible to automatically change the generated URLs when…

Templates

Templates are text files marked up using the Zotonic template language. Zotonic interprets that mark-up to dynamically…