# controller\_id

Source: https://zotonic.com/docs/1567/controller_id

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

Language: en



Handle different content representations of a page.

Redirects to different representations of a page, depending on the requested content type. The redirect is done using a “303 See Other” status. A “404 Not Found” or “410 Gone” is returned if the requested page never existed or has been deleted.

When no content types are requested then `text/html` is selected.

This controller is also used for a page’s short url representation.

Example dispatch rule (from mod\_base):

```erlang
{id, ["id", id], controller_id, []}
```

This controller does not have any dispatch options.

This controller handles the following query argument:

| Option | Description                                                     | Example URL |
| ------ | --------------------------------------------------------------- | ----------- |
| `id`   | Id of the requested [resource](/id/doc_glossary#term-resource). | `/id/1234`  |

The list of provided content types is collected with a foldr notification (see [Notifications](/id/doc_developerguide_notifications#guide-notification)) of the type `content_types_dispatch`. Modules should add their provided content types in front of the accumulator. The added entries are tuples: `{MimeType, DispatchRuleName}`.

Example of adding a content type handler adding a text/plain handler with the dispatch rule `rsc_text`:

```erlang
observe_content_types_dispatch(#content_types_dispatch{}, Acc, _Context) ->
    [{"text/plain", rsc_text} | Acc].
```

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1567?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/1567?language=en>)
