controller_template

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:

ArgumentDescriptionExample URL
idA 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:

OptionDescriptionExample
templateName 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”\}\}
anonymousRender the template always as the anonymous user, even when a user is logged on. Defaults to false.\{anonymous, true\}
content_typeThe content type provided by the dispatch rule. Defaults to “text/html”.\{content_type, “application/json”\}
max_ageThe number of seconds of how long to cache this file in the browser. Sets the response header: Cache-control: public; max-age=X.\{max_age, 3600\}
acl_actionWhat 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\}
aclExtra authorization checks to be performed.See ACL options.
idId or unique name of a resource to be referenced in the rendered template. This overrules and id from the query arguments.\{id, page_about\}
seo_noindexAsk crawlers to not index this page.seo_noindex
nocachePrevent browser caching this page.nocache
http_statusThe HTTP status code to return. This defaults to 200.\{http_status, 418\}

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 optionDescriptionExample
is_authDisable anonymous access to this resource.{acl, is_auth}
logoffLog 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\} > \]\}
ignoreDon’t perform any access control checks. Be careful to add your own checks in the rendered template and all its included templates.{acl, ignore}

See also

controller_page.

Edit on GitHub

controller_static_pages Controllers controller_website_redirect

Referred by

Access control

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