How to Create a Block

To create a block, do the following steps:

  1. Choose a block name. The block name must be alphanumeric only. In this example, we will name it as GoogleTranslate (camel case recommended)
  2. Create a folder with the same name as the block name but all in lower-case.
  3. Create the main block class file googletranslate.class.php
  4. Create a configuration file config.template.php

The content of googletranslate.class.php is as follows:

namespace Block;

class GoogleTranslate extends \SCHLIX\cmsBlock
{
    public function getEnabledLanguages()
    {
        if ($this->config['array_languages'])
        {
            $show_languages = implode(',', $this->config['array_languages']);
        }
        return $show_languages ? ",includedLanguages:'{$show_languages}'" : '';
    }


    public function Run()
    {
            $config = $this->config;
            $this->loadTemplateFile('view.block',compact(array_keys(get_defined_vars())));
    }
}

The block must have Block namespace and inherits from \SCHLIX\cmsBlock.

Download the actual example from here.