This Module enhances your template with customization features. It allows you to create and include the template components on the page and even pass parameters to them.

SimpleComponents image

Module Description

This is a simple and easy to use module for creating dynamic template elements such as sidebar, headers, editable containers, etc. The template components may contain code, variables or text that can be inserted into a template to dynamically display specific template areas.

Install Instruction

Download the zip file, unzip it and upload the complete folder SimpleComponents to your server/webspace in the directory site/modules/.

Open your custom.scriptor-config.php file and add the following configuration to the modules section:

'modules' => [
    'components' => [
        'menu' => 'cm_list_menu',
        'position' => 3,
        'active' => true,
        'auth' => true,
        'autoinit' => true,
        'path' =>  'modules/SimpleComponents/ComponentsEditor',
        'class' => 'ComponentsEditor',
        'display_type' => [
            'sidebar'
        ],
        'icon' => 'gg-components',
        'description' => "Components Editor"
    ],
    'SimpleComponents' => [
        'menu' => '',
        'position' => 0,
        'active' => true,
        'auth' => false,
        'autoinit' => true,
        'path' =>  'modules/SimpleComponents/ComponentsController',
        'class' => 'ComponentsController',
        'display_type' => [],
        'description' => "SimpleComponents frontend module controller"
    ]
]

Log in to the Scriptor editor area. If the installation was successful, you should now see an additional item Components in the navigation.

Usage

Loading the SimpleComponents module in your template:

$components = $site->loadModule('SimpleComponents');

To display a component in your template, use this code:

$component = $components->get('your-component-name'); 
echo $component->getContent();

Passing the variables to your component:

$vars = [
    'var_1' => 'Value #1',
    'var_2' => 'Value #2'
];
echo $component->getContent($vars);

Here's an example

Open the Components menu in Scriptor editor and create the following component:

Create Component Example

You can use your component at the frontend (in your template) as follows. To get an instance of the SimpleComponents module use loadModule method:

$components = $site->loadModule('SimpleComponents');

Find your component by name:

$component = $components->get('info-text'); 

Define values to replace the placeholders:

$vars = [
    'author' => 'George Lucas',
    'created_date' => date('Y/m/d', $component->created)
];

Finally, output the component:

echo $component->getContent($vars);

Output:

Component output

Minimum requirements

Compatible with Scriptor: 1.4.9 +
Author: Bigin
Last Updated: 2020-09-02
SimpleComponents: 1.0.1