Block and region system - CityWebConsultants/Iris GitHub Wiki

Blocks are reusable elements that produce HTML and can be slotted into a region in a theme. To use blocks you will need to enable the blocks module. You will also, unless you are creating your own block type, need to enable one of the block type modules.

Blocks can be created via the admin system by going to structure > blocks.

If you do not want to use the region system you can simply add a block to an HTML template with a block embed code.

For example:

{{{iris embed="block" block="my_block"}}}

Adding blocks to regions

Regions are elements in a theme that contain a list of instances of a block type.

Once you have created some block instances from the available block types (see the blocks section) you can add them to a region in your theme using the form on the regions page within the structure section of the administration system.

Each block has a path visibility section. This uses the minimatch system to list (each on a new line) the paths the block is visible at on the site. Full documentation on how this works can be found on the Minimatch project page at https://github.com/isaacs/minimatch .

Which regions are available depends on the contents of the yourtheme.iris.theme file in your theme folder. To add a new region, add it to the region section of that file.

Adding a region to your theme

To add a region to your theme, use a regions embed code giving it your region name. For example:

{{{iris embed="region" region="sidebar"}}}

Defining a custom block type

Registering the block type

Use the block module's registerBlockType function to register a block type.

iris.modules.blocks.globals.registerBlockType('My block type');

Registering the form for the block's configuration

Use hook_form_render_blockForm_YOURBLOCKTYPE to set/alter a form used for the block's configuration.

What happens when you view a block


iris.modules.lists.registerHook("hook_block_render", 0, function (thisHook, data) {

  var config = thisHook.context.config;
  var type = thisHook.context.type;

// Do something 

data = "" // HTML you want to return for the block.

thisHook.pass(data);