WebsiteBaker modules consists of text files such as PHP, HTML, Javascript and CSS. This chapter provides a brief introduction of the different module files and its purpose depending on the different module types. This is the basic knowledge required for the creation of own modules.
There are two files which are required (or recommended) for all modules:
<?php /** Copyright (C) 2018, Your name This module is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License - version 2 or later, as published by the Free Software Foundation: http://www.gnu.org/licenses/gpl.html. This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------- Module: XXX for WebsiteBaker v2.10.x (https://www.websitebaker.org) Module description ------------------------------------------------------------------------------- v0.10 (Your name; 11.06.2018) + initial release of the module ------------------------------------------------------------------------------- **/ /* -------------------------------------------------------- */ // Must include code to stop this file being accessed directly if (!defined('SYSTEM_RUN')) { header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); flush(); exit; } /* -------------------------------------------------------- */ $module_directory = 'specify desired module directory'; $module_name = 'Specify module name (displayed as page type)'; $module_function = 'page, tool or snippet'; $module_version = '0.10'; $module_platform = '2.10.x'; $module_author = 'Your name'; $module_license = 'GNU General Public License'; $module_description = 'Short description of the Module';
The opening PHP tag (<?php) is followed by a multiline comments block (/** ... **/) which provides optional information about the choosen module license, a disclaimer and the module development history.
The module variables provides the required information for WebsiteBaker. The variable $module_function defines whether the module is a page type module (page), a administration tool (tool) or a code snippet (snippet). The closing PHP Tag (?>) is not needed.
The index.php file prevents the listing of files and folder contained in the module directory independent of your server settings. This is a simple measure to enhance security as no additional information about the module architecture will be displayed.
<?php header('Location: ../index.php'); ?>
The following files are optional and can be used to execute code during installation and uninstallation process. This files are automaticall invoked from the WebsiteBaker backend: Add-Ons -> Module -> Install Module / Uninstall Module.
The content of those files depends from the modules purpose. A working example can be found with the Hello World Module from the Add-Ons Repository.
A page type module requires to set the variable in the info.php as follows:
$module_function = page;
Page type modules can contain the following files:
The content of those files depends from the modules purpose. A working example can be found with the Hello World Module from the Add-Ons Repository.
A administration tool requires to set the variable in the info.php as follows:
$module_function = tool;
Administration tools contain the following file:
A code snippet requires to set the variable in the info.php as follows:
$module_function = snippet;
All functions contained in the following file can be invoked from the index.php file of your template or from a page/section of type code: