Reference > controller

The controller is the part of the module which responds to user actions.

Most of the time, the action is triggered by the click of a link, from within a view.

You can create several controllers if that makes sense (one 'user' related controller, one 'product' related one etc).

Each method of the controller has the name of the action it stands for.

If the name of an action is a PHP reserved word, you should append an underscore to the name of the action.

Ex: "list" action's method should be "function list_()".

An action displays the result of its operations in a view named after the same name. No special call is required, unless you want to display the result with another view.

methods you can call from within an action

$this->redirect_to($action, [$controller])

Redirects to another action, by default in the current controller.

$this->render($action, [$controller])

Sometimes you may want to render an action through the view of another one.

Just call $this->render('anotheraction', 'anothercontroller') from an action method and the action will be rendered that way.