Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Howto: Adding blocks into spaces presets

Amitai Burstein edited this page Mar 13, 2014 · 3 revisions

Space preset is a set of configuration which will be a default behavior for a new space.
In the current OpenScholar case, we are talking about a VSite space.

When creating a VSite, the user selects which preset to use. Accordingly, by default, all of the selected configuration will be enabled.

When adding blocks into presets, we want to add it just for certain pages (or other conditions), and this is done by using contexts. On the other side, we don't want to add the block into the site-wide context, since we want to enable it specifically for a VSite.

Step 1:

Get into admin/structure/context to find the context you want to use. Look into the conditions of the context to verify this is what you need, and remember the context machine name (for example, blog_blog is the context for blog-related context).

Step 2:

Via the context UI add the block you want to it, and use the 'export' link to see how the block suppose to be. For example:

'views-os_blog-block' => array(
  'module' => 'views',
  'delta' => 'os_blog-block',
  'region' => 'sidebar_second',
  'weight' => '-8',
),

Save this block for next step.

Step 3:

The block needs to be added to the spaces preset object in a certain format.
In the "value" section it should be added to the context part, using the key <context name>:reaction:block, into the 'blocks' value.
For example:

'blog_blog' => array(
  'blocks' => array(
     'views-os_blog-block' => array(
       'module' => 'views',
       'delta' => 'os_blog-block',
       'region' => 'sidebar_second',
       'weight' => '-8',
     ),
  ),
),

Clone this wiki locally