Modules allow you to create custom controls such as contact forms to extend the functionality of SiempreCMS.
Creating a New Module
Copy the sample HelloWorld folder in the modules directory and rename the files inside. Ensure that the folders are lower case (e.g. “helloworld”) and the MVC classes are in CamelCase (e.g. “HelloWorld”).
Including in the Template
To use the module in the template use the following:
This should now output our test info.
Coding your Module
Now just change the MVC files to develop your module.
Handling POSTs GETs
These need configuring in SiempreCMS to route the POSTS and GETs to the relevant module. We’ve seen above how to output something in the template.
Forthcoming Module Functionality
The following items are not yet available in SiempreCMS:
- Access SiempreCMS content from a module that’s not a related page.
- MVC style wild card trapping - e.g. /news/page-1 /news/page-x
Included Module Examples
Included are a Contact Us form and a Main Navigation (used for menus).
Include the code below in your template and check the files in the /modules/contactus/ folder to configure.
Include the code below in your template, add a node picker to the sitesettings node and name this MainNavigation. Pick some content pages in this and then modify the /modules/mainnavigation.view.php file to change the output markup to match your navigation.