Commentics uses a custom-made MVC (Model-View-Controller) framework.

This means that the code is split into 3 parts:


The controller orchestrates everything. It gets any user-submitted data, uses a model (or more) to do all the work and finally decides which view to display. It understands the why. Controllers should be as small as possible. Typically each page has its own controller meaning controllers aren't re-usable.


The model is loaded by the controller. It does all the hard work like reading from and saving to the database, sending emails and writing to files. Models don't understand the why but they do know the how. A good model is a re-usable one (allowing other controllers to use it). One controller might load many models.


The view is loaded by the controller. Its purpose is to display the HTML. The view shouldn't have any "logic" code inside. The logic is separated and should be "passed down" by the controller. A good view should allow a frontend developer to work on it without having to know any backend code.


In Commentics we can see that in the 'backend', 'frontend' and 'install' folders, the code is split up into the above MVC pattern.


We also have the /system/library/ files. These make it easier for the controllers and models by providing the code they need to do very rudimentary things like querying the database, encrypting data and accessing the session.

Other places worth mentioning:

  • /3rdparty/ These are the external scripts used by the application
  • /system/backups/ This is where the 'Tool -> Database Backup' feature stores its backups
  • /system/cache/ This is where the database, modification and template cache is stored
  • /system/engine/ These are the core classes that the controllers and models extend from
  • /system/helper/ This is code that assists the application but doesn't fit anywhere
  • /system/logs/ This is where the log files are stored such as the error log
  • /system/modification/ This is where the XML modification files are stored
  • /system/startup.php This file includes all of the other files
  • /upload/ This is where user-uploaded images are kept

To route to the method of a controller, simply use something like:


In the above URL, 'main' is the folder, 'dashboard' is the file and 'dismiss' is the method.

By omitting the method, the index() method will be called. Note that magic methods such as __construct() are blocked. Make sure the method is public.