Skip to content

04. Controller Class

Simon Striekwold edited this page Mar 20, 2018 · 2 revisions

All properties and methods in the Controller class:

Properties

$layout

The layout that will be rendered when Smts::Render() is called.

This defaults to main.

To change the layout in an action:

self::$layout = 'secondary';

$title

The value of the <title> tag in the rendered layout.

By default this is the value of DefaultTitle in the config.

To change the title in an action:

self::$title = 'Home';

Methods

beforeAction

As the name implies, beforeAction is called before every action. It can therefore be used to do something for every action in a controller.

For example, if you wanted an admin check for every page in a controller you could do something like:

public static function beforeAction( $var ) {

    if ( !User::isAdmin() ) {
        Smts::Redirect( Smts::$config . 'login' );
    }

}
Clone this wiki locally