Anatomy of a Controller

Admin panel and Module controllers should extend InvController. Public website controllers should extend InvPublicController.

Below are a few notes on how to use/extend InvController and InvPublicController.

Filenames, URLs and class names

Filenames and classname follow a simple pattern. For example: to create a controller at http://sitedomain/example, we would create:


example.controller.class.php would contain a simple class:

class ExampleController extends InvController{

    public function __construct($obj_db , $obj_session , $view_template , $path_info){
        parent::__construct($obj_db , $obj_session , $view_template , $path_info);
        $this->view_title = 'Example';

    protected function setInputValues(){                

    public function doController(){



__construct($obj_db , $obj_session , $view_template , $path_info){
        parent::__construct($obj_db , $obj_session , $view_template , $path_info);
        $this->view_title = 'Create Server'; // Set the title of your new view here - this will appear in 

$this->view_title will appear in the <title> tag of your page when viewed.


This is where you should set up the user / session input values for your controller more details here


Once your input has been set up, doController() will run. This is where you should manage the processing of user input and the generation of output. You can add other methods to the controller to do this and also instantiate external classes.

Create object properties for your output. After doController has completed, the controller class will load include your view template. which should have the same filename as your controller. this will access the object properties for display.

View / Template Build Order

A dotAdmin controller assembles its view by loading the top template, then the view template for the controller, then the bottom template:

  1. $this->template_top
  2. $this->view_template
  3. $this->template_bottom

These are set by default as follows:

  • $this->template_top = 'top'
  • $this->view_template = [PATH TO CONTROLLER] . [CONTROLLER_NAME]
  • $this->template_bottom = 'bottom'

The Top and Bottom templates will be loaded from /path/to/dotadmin/shared/template/[$template].html

The view template is loaded using the $this->getTemplate() method, and will load from one of a number of different possible locations, depending on where it can be found. It loads using the standard template load order:

  2. [THEME_PATH] . 'default/' . [PATH_TO_TEMPLATE] . '.html'
  4. [SHARED_PATH] . 'view' . [PATH_TO_TEMPLATE] . '.html'

CSRF protection

All controllers by default require a CSRF prevention token. If the token is not present in the GET / POST data, then all user input will be silently ignored, and the $this->arr_input array will be empty.

If you need your controller to accept input without requiring a CSRF token (this can be quite useful for API endpoints, or a URL is going to shared on third party website complete with GET component in the URL), you will need to tell your controller to not require the CSRF token by adding a line into the __construct() method:

    public function __construct($obj_db , $obj_session , $view_template , $path_info){
        $this->token_exempt = true; //<-- THIS CONTROLLER DOES NOT REQUIRE A CSRF PREVENTION TOKEN
        parent::__construct($obj_db , $obj_session , $view_template , $path_info);
        $this->view_title = 'Example';

Additional path arguments

You can also allow your controller to accept additional arguments in the URL path. For example, a controller called "Widget" might accept arguments for the widget id and size, giving you a URL such as [website_domain]/widget/1234/large

In order to do this, you need to tell the controller to expect additional argument in the path, by specifying the maximum number of arguments which can appear after the controller name in the path. This is done by setting the $this->max_path_length property at the start of your controller:

__construct($obj_db , $obj_session , $view_template , $path_info){
        $this->max_path_length = 2;
        parent::__construct($obj_db , $obj_session , $view_template , $path_info);
        $this->view_title = 'Create Server'; // Set the title of your new view here - this will appear in 

The additional path arguments will then be available in the controller in an array $this->path_info. eg:


    [0] => 1234 ,
    [1] => 'large'

Contact Us

Address: 22a Fishergate York, YO10 4AB · Tel: 01904 636677 · Email: