The modules are used to divide Scriptor CMS into smaller, easier to manage parts and allow you to extend the core functionality or add as much functionality as you want. A module can be a file or a bundle of files, that containing a class that adheres to Scriptor's Module interface. A major part of Scriptor itself is a collection of various modules. Indeed, the Scriptor's Editor (admin) application is just a group of modules.

Core modules and custom modules

In Scriptor CMS there are core modules and custom modules. Core modules are modules that come with the core and are pre-installed because they represent a major part of Scriptor's functionality. The core modules are stored under /editor/modules/ directory. On the other hand, custom modules are those that you obtain separately or create and install yourself. You install the custom modules in the /site/modules/ directory.

Installing custom modules

Installing a custom module is as easy as uploading the module's files to the /site/modules/ModuleName/ directory on your server - where ModuleName is the name of the module folder.

Modules are not enabled by default. An uploaded module must be activated in the custom.scriptor-config.php file.

Let's take a quick look at the example of a module activation of a module called TestModule in the custom.scriptor-config.php file:

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

// Enter here the configuration parameters that you want to overwrite, e.g:   
$config = array_replace_recursive($config, [
    'modules' => [
        'TestModule' => [
            'menu' => '',
            'position' => 0,
            'active' => true,
            'auth' => false,
            'autoinit' => true,
            'path' =>  'modules/test/TestModule',
            'class' => 'TestModule',
            'display_type' => [
            ],
            'description' => "Scriptor's test module to display 'Hello World' message."
        ]
    ]
]);

Now, look at the specific parameters of the array:

'TestModule' => [ // module name (array key) 
'menu' => '', // i18n variable name (string) 
'position' => 0, // module position 
'active' => true, // activates/deactivates module
'auth' => false, // is authentication required to run this module?
'autoinit' => true, // should module be initialized automatically (bool)?
/* Relative path to the module, where the last part after the slash 
represents the file name of the module without ".php" extension. */
'path' =>  'modules/test/TestModule',
'class' => 'TestModule', // module class
'display_type' => [ // defines where a link to call the modules should be displayed.

Some modules require you to insert a part of their code into your theme to make it executable. Depending on the module and the method it was written, such a call might look something like this:

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

 

You may also create your own modules, which is easy to do – see our chapter on › module development.