-
Notifications
You must be signed in to change notification settings - Fork 61
DEVELOPER DOCUMENTATION > MVC STRUCTURE
The Core software is moving towards a general MVC-type architecture, with our own specific flavor.
- Controls the flow of execution, for any content related to the user action.
- Sends updates to the model, as result of user actions.
- Retrieves information from the model, as necessary.
- Gives data to the view.
ElkArte core controllers are in /admin and /controllers folders.
- Receives from the controller data to present.
- It displays in any format or way.
Templates, and generally themes, play the role of view.
- Deals with the data, the information the application works with.
- Adds, retrieves, updates, removes information from the database.
ElkArte has .subs files, and classes in /subs folder, to play the role of 'model'.
Add-ons can easily be designed in a similar way. This section concerns mainly medium-big add-ons, and/or add-ons which add actions of their own. (;action=)
Add-ons can be installed anywhere, but it is recommended for them to have their own folders, in /packages directory.
Mockup sample: https://github.com/norv/elkarte/tree/dirs_test6/addons/gallery
Add-ons can use two ways to add custom actions to the forum:
- Register their own action through a hook; or,
- Make a controller file for the action, respecting the following placement and naming patterns.
Lets say the action is 'home'.- /addon_dir/controllers/HomeController.controller.php
- HomeController is a class (with a public constructor with no parameters, ElkArte will create it automagically)
- With a method called action_home().
Implement your home page starting with this method, and ElkArte will load and display it to the user when the add-on is installed, without other need to register it separately.
We recommend that you structure the rest of your add-on files in a similar way as described above:
- If you have any database calls to make, make a .subs file (or more) for functions working with the database. Load and execute them from the controller, where needed by your feature.
- If you have data to display to the user (who doesn't? ;)), make a .template file (or more) for your sub-templates. In the controller method, set the template file and sub-template in the contextual array.
Architecture
- Architecture
- [Coding Standards](Coding Standards)
- [Database Layer](Database layer)
- MVC
- Release
Functions and Variables
- About $user_info variable
- About the createList() function.
- About [Template Layers](Template layers).
- About [is_activated](is activated) values.
Customization
- [Create a theme](Make a new theme)
- [Create an Addon](Create an Addon)
GitHub