CHAPTER IV



Direct access to a module

Pages work well up to this point, but some services offered by the website may not make sense as pages: a web service, for example, or a controller handling AJAX requests.

Pages must therefore not be the only way to call module controllers: we also need to access modules directly through a URL.

This introduces a new element: the page selector.

Direct access to a module: illustration

For this purpose, the first argument of our request contains the string 'modulo'.

http://cms.um/modulo/noticias/votes/vote/positive/123

https://borjaabad.com/modulo/modname/controller/method/argument/arg/s

Direct access to a module: illustration

The illustration shows that the system is designed around pages, which are assumed to constitute the website.

When a page loads, all its modules already have access to every Application class. A single instance of the system thus manages the loading of the page's modules.

Here is an excerpt from the Request class implementing the above:

//https://borjaabad.com/modulo/modname/controlador/metodo/arg/s
if ($this->first == 'modulo') {//Load module
         $this->_modulo = strtolower(array_shift($url));
         $this->_controlador = strtolower(array_shift($url));
         $this->_metodo = strtolower(array_shift($url));
         $this->_argumentos = $url;
         $modulo = $this->_modulo;
}




CMS UM header