Show a template.

This controller renders the template configured in the dispatch rules.

Example dispatch rule:

{home, [], controller_template, [{template, "home.tpl"}]}

This will render the home.tpl template at the url /.

Dispatch arguments

controller_template recognizes the following arguments inside the dispatch pattern:

Argument Description Example URL
id A resource id to be used in the template. This can be the numerical id or the unique name of a page. More commonly the id is given as a dispatch option. /page/12345

Dispatch options

The following options can be given to the dispatch rule:

Option Description Example
template Name of the template to be rendered. Can also be a tuple of the following form: {cat, Name}. See also: catinclude. {template, “home.tpl”} {template, {cat, “home. tpl”}}
anonymous Render the template always as the anonymous user, even when an user is logged on. Defaults to false. {anonymous, true}
content_type The content type provided by the dispatch rule. Defaults to “text/html”. {content_type, “application/json”}
maxage The number of seconds of how long to cache this file in the browser. Sets the response header: Cache-control: public; maxage=X. {maxage, 3600}
acl_action What ACL action will be checked. Defaults to ‘view’; but can also be ‘edit’ if users need edit permission on the rsc to be able to access the resource. {acl_action, edit}
acl Extra authorization checks to be performed. See ACL options.
id Id or unique name of a resource to be referenced in the rendered template. This overrules and id from the query arguments. {id, page_about}

ACL options

Authorization checks to perform, in addition to the acl_action dispatch option, can be given in the acl dispatch option, and accepts the following options:

ACL option Description Example
is_auth Disable anonymous access to this resource. {acl, is_auth}
logoff Log out user before processing the request. {acl, logoff}
{Action, Resource} Check if user is allowed to perform Action on Resource. The example is equivalent to the options {acl_action, edit}, {id, my_named_page}. {acl, {edit, my_named_page}}
[{Action, Resource}] A list of checks to be performed, as above. {acl, [{view, secret_page}, {update, 345}]}

See also


Table Of Contents

Previous topic


Next topic