Modules are a fundamental aspect of Scriptor CMS, allowing you to divide the system into smaller, more manageable parts and extend its core functionality. A module can be a single file or a collection of files that contains a class adhering to Scriptor's Module interface.

Scriptor itself is primarily composed of various modules, and even the Editor (admin) application is essentially a group of modules working together.

Core Modules and Custom Modules

In Scriptor CMS, you will find core modules and custom modules. Core modules come bundled with the Scriptor core and are pre-installed because they represent a significant part of Scriptor's functionality. These core modules are stored in the /editor/modules/ directory.

On the other hand, custom modules are those obtained separately or created by users. Custom modules need to be installed manually by uploading their files to the /site/modules/ModuleName/ directory on your server, where ModuleName is the name of the module folder.

Installing Custom Modules with the Module Manager

Scriptor CMS offers a convenient method for installing custom modules using the Module Manager. This core module simplifies the installation and uninstallation process by automatically updating the custom.scriptor-config.php file with the necessary parameters.

To access the Module Manager, click on the "Modules" button, which will take you to the Module Manager section.

For a module to appear in the installation or uninstallation list, it must have an install or uninstall routine and be located in the directory site/modules/<ModuleName>.

To ensure compatibility, all installable modules must follow this file structure: site/modules/<ModuleName>/<ModuleName.php>. The corresponding module class should have the same name as the directory and PHP file.

Please note that the Installation Manager requires write permissions for the custom.scriptor-config.php file. In some cases, certain modules may require modifications to other files. You will typically find specific instructions in the module's description.

Installing a custom module is straightforward. Simply upload the module's files to the appropriate directory on your server and follow these steps:

  1. Access the Scriptor CMS administration area.
  2. Click on the "Modules" button to open the Module Manager.
  3. In the Module Manager, you will find a list of available modules for installation.
  4. Locate the module you wish to install and click on the "Install" button next to it.
  5. The Module Manager will automatically update the custom.scriptor-config.php file with the necessary installation parameters for the module.
  6. Once the installation is complete, the module will be ready to use within your Scriptor CMS installation.

Please note that some modules may require additional configuration or integration steps, which should be provided in the module's documentation or description.

The Module Manager in Scriptor CMS simplifies the management and installation of custom modules, allowing you to enhance the functionality of your CMS effortlessly. Enjoy the flexibility and extensibility provided by custom modules in Scriptor CMS.

Installing Custom Modules Manually

Installing a custom module involves uploading the module's files to the appropriate directory on your server and activating it in the custom.scriptor-config.php file.

To activate a custom module, add an entry for it in the modules section of the custom.scriptor-config.php file. Here's an example of activating a module named TestModule:

<?php defined('IS_IM') or die('You cannot access this page directly');

return [
    'modules' => [
        'TestModule' => [
            'menu' => '',
            'position' => 0,
            'active' => true,
            'auth' => false,
            'autoinit' => true,
            'path' => 'modules/test/TestModule',
            'class' => 'Scriptor/Site/Modules/TestModule',
            'display_type' => [],
            'description' => "Scriptor's test module to display 'Hello World' message."

In this example, you provide the module name, menu item name, position, activation status, authentication requirement, auto-initialization, module file path, class name, display type, and a description of the module.

Let's take a closer look at the specific parameters in the array:

'TestModule': The module name (array key).

'menu' => '': The i18n variable name (string).

'position' => 0: The module position.

'active' => true: Activates/deactivates the module.

'auth' => false: Specifies whether authentication is required to run this module.

'autoinit' => true: Determines if the module should be initialized automatically (boolean).

'path' => 'modules/test/TestModule': The relative path to the module, where the last part after the slash represents the file name of the module without the ".php" extension.

'class' => 'Scriptor\Site\Modules\TestModule': The full namespace and class name.

'display_type' => []: Defines where a link to call the module should be displayed.

Once activated, you can access the module and utilize its functionality. Some modules may require you to insert specific code into your theme to make them executable. Depending on the module and its implementation, this may involve calling specific functions or methods provided by the module:

$testModule = $site->loadModule('TestModule');
if ($testModule) {
    echo $testModule->execute();

You can also create your own modules, which is a straightforward process. More information on module development can be found in the module development chapter, which covers the process of creating custom modules.