# controller\_page

Source: https://zotonic.com/docs/1534/controller_page

URI: https://zotonic.com/id/1534

Language: en



Show a rsc as a HTML page.

This controller is used to show the HTML page of a [resource](/id/doc_glossary#term-resource). A “404 Not Found” or “410 Gone” page is shown if the requested page never existed or has been deleted.

The user will be redirected to the `logon` URL when the current user is not allowed to view the page.

This controller also adds a `noindex` response header when the page’s `seo_noindex` flag, documented by <a href="/id/doc_module_mod_seo" class="doc-reference doc-reference-module"><code>module#mod_seo</code></a>, is set.

Example dispatch rule:

```erlang
{page, ["page", id], controller_page, []}
```

Dispatch arguments
------------------

`controller_page` recognizes the following arguments inside the dispatch pattern:

| Argument | Description                                                                      | Example URL   |
| -------- | -------------------------------------------------------------------------------- | ------------- |
| `id`     | The id of the page (rsc) to be shown. This can be the numerical id or the unique name of a page. | `/page/12345` |

Dispatch options
----------------

The following options can be given to the dispatch rule:

| Option         | Description                                                                      | Example                                                    |
| -------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `id`           | Id or unique name of the resource to be shown. This overrules any id in the query arguments. Use `user_id` for the id of the current user. | `{id, page_about}`                                         |
| `template`     | Name of the template to be rendered. Defaults to “page.tpl” Can also be a tuple of the following form: `{cat, Name}`. See also: <a href="/id/doc_template_tag_tag_catinclude" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a>. | `{template, "about.tpl"}` `{template, {cat, "home. tpl"}}` |
| `cat`          | The category the resource that is requested has to be. If a page of a different category is requested, a 404 is shown. | `{cat, text}`                                              |
| `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](#acl-options).                           |
| `is_canonical` | Whether this URL should be considered the canonical URL of the page. If so, the controller will redirect to the rsc’s page path if set. Defaults to true. | `{is_canonical, false}`                                    |
| `seo_noindex`  | Ask crawlers to not index this page.                                             | `seo_noindex`                                              |
| `nocache`      | Prevent browser caching this page.                                               | `nocache`                                                  |

ACL options
-----------

[Authorization](/id/doc_developerguide_access_control#guide-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}]}` |
| `ignore`               | Don’t perform any access control checks. Be careful to add your own checks in the rendered template and all its included templates. | `{acl, ignore}`                               |

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1534?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1534?language=en>)
