WebBasic CMS
References

Modules

Modules are designed to integrate WebBasic with the API of third-party sites and applications, as well as create your own extensions to the system. Examples include the modules of integration of payment systems, cartographic information, file manager included in the system, etc.

Newly created modules must be in the subdirectory /modules and in the subdirectory with the module name enclosed in it.

For example : /modules/mymodule/mymodule.php

The specified file must contain a function named mymodule_init(), which initializes the module and returns the result of the module operation.

<?php
function mymodule_init()
{
    if (isset($_ENV["route"]["params"][0])) {
        $mode=$_ENV["route"]["params"][0];
        $call="mymodule__{$mode}";
        if (is_callable($call)) {
            $out=@$call();
        }
        die;
    } else {
        $out=file_get_contents(__DIR__ ."/mymodule_ui.php");
    }
    return $out;
?>

In addition to the php file with module functions, other files, such as template files, styles, scripts, etc., can be contained in the module folder.

The module is connected to the template using the HTML instruction:

<div data-wb-role="module" src="mymodule"></div>

Instead of the instruction, the code generated by the module will be substituted.