zajController is the base class for handling requests in your controller files. Controllers must follow these requirements:

  • each controller must be in a separate file and must be placed in /app/controller/ or another plugin or system controller folder
  • the file must be named *.ctl.php where * is the name of your controller
  • the class must extend zajController
  • the class must be named zajapp_* where * is the name of your controller

Controller methods are typically automatically called in one of the following ways:

  • an incoming request is routed automatically to a controller method. see handling requests for details on how this works
  • a $this->zajlib->reroute() method (see docs) is invoked manually, typically from another controller method
  • using the {% include %} in a view (see docs). you can use this to route requests back from views to controllers when inline processing is needed. use this sparingly – improper use breaks the MVC pattern!


All controller object have the following properties:

  • zajlib – a pointer to the global zajlib object.
  • name – the name of the current app.


The __load() magic method is run each time this particular controller is used to process the request. You should place code here which is general for all related requests. For example, an admin.ctl.php file’s __load() method will likely contain an authentication process, so that anyone requesting any admin pages will need to login first…

@param array $optional_parameters This is only specified when the request is coming from another app and $optional_parameters were given. Also when you reroute() or {% include %} any additional parameters are passed as an array.
@return mixed You can return any value here. This will be returned when you invoke $this->zajlib->load->controller('my_controller.ctl.php');.


This method will handle all requests which could not be routed anywhere. You can use this method to handle 404 errors or it can also be used to handle friendly url requests.

@param string $request A string of the actual request. All slashes are converted_to_underscore.
@param array $optional_parameters This is only specified when you reroute() or {% include %} – any optional parameters are passed as an array.
@return bool Returns false and displays error message.


Any other methods act as receivers of requests within the controller class.

The basic is that all slashes are converted_to_underscores so would be routed to (for example) something.ctl.php / to_try().

Take a look at handling requests to see how request handling works.

Also check out documentation on plugins and hierarchy to see how controllers can override and decorate each other.

By default no parameters are passed to controller methods. But you can pass parameters when you manually invoke methods using reroute() (see docs) or {% include %} (see docs).
@param mixed $optional_param_1 Any parameter passed by manually invoking the method.
@param mixed $optional_param_2 etc…

Outlast Web & Mobile Development (c) 2018 | Privacy Policy |