Minisites in Open Atrium

Antonio De Marco
28 Nov 2011
18 Comments
Antonio De Marco
28 Nov 2011
18 Comments
Antonio De Marco, 28 Nov 2011 - 18 Comments

Minisites in Open Atrium

A single Open Atrium installation to serve minisites from different domains with a common backend

You can use a single Open Atrium installation to create minisites, i.e., minimal websites with a simple structure, served at different domains, but sharing a centralized backend. Each minisite can be public or private and can have a specific theme and specific features. An anonymous visitor will only see a small, self-contained site, while site editors will be able to manage content on all minisites from the same backend.

This is an ideal situation, for example, when an Open Atrium installation is used as a private Intranet but you want to build small auxiliary sites for conferences or events, and possibly take advantage of the fact that editors and registered users are the same as the main Intranet.

And, best of all, this can be done with a minimal amount of coding and respecting the Open Atrium architecture.

Creating and Customizing a Minisite

Our aim is to build a feature that will allow us to create and customize a minisite in just a few minutes. We want to start from the ordinary "Create Group" page:

minisite-create.jpg

And this is what we get immediately upon form submission:

minisite-new-1.png

The minisite ships with default content (pages linked from the left side menu) and the editor can just click and add content.

We can also hook our minisite to the built-in look-and-feel customization that Open Atrium provides for its groups and give the possibility to the editor to choose background and foreground colors:

minisite-color.png

After a quick content editing, the editor can achieve something like this:

minisite-custom-1.png

Screenshots are taken from Alfa Puentes, an international project funded by the EU that will focus on exchanging best practices between Europe and Latin America about higher education and that will include several events and conferences, each with a dedicated minisite.

Let's now see how to build this feature in Open Atrium.

Creating a minisite group type (spaces preset)

To start, we simply define a new spaces preset type, named "minisite": this can be done through hook_spaces_presets() using the existing definitions for public and private spaces from atrium_groups.spaces.inc as a basis.

<?php

function atrium_minisite_spaces_presets() {
 
$export = array();

 
$spaces_presets = new stdClass;
 
$spaces_presets->disabled = FALSE;
 
$spaces_presets->api_version = 3;
 
$spaces_presets->name = 'minisite';
 
$spaces_presets->title = 'Minisite';
 
$spaces_presets->description = 'Minisite space preset.';
 
$spaces_presets->space_type = 'og';
   ...
?>

The new space preset can be exported into a feature and creating a minisite becomes as easy as creating a new group.

minisite-create.jpg

Assigning features to a minisite

Just like a standard Open Atrium group has some features available by default, we will want our minisites to use a certain set of features by default. In our case, we built two features for Pages and News and we enable them for our minisites, that will thus have static pages and news available.

<?php

 
... (follows from above) ...
 
$spaces_presets->value = array(
   
'variable' => array(
     
'spaces_features' => array(
       
'atrium_blog' => 1,
       
'atrium_book' => 0,
       
'atrium_calendar' => 1,
       
'atrium_casetracker' => 0,
       
'atrium_members' => 1,
       
'atrium_pages' => 1,
       
'atrium_shoutbox' => 0,
       
'spaces_dashboard' => 1,
       
'atrium_news' => 1,
      ),
  ... (continue
along the lines of atrium_groups.spaces.inc) ...
?>

Making minisites self-contained: menus and blocks

We want our minisites to be self-contained as much as possible. In order to achieve that, with some standard Drupal hooks, we create a new menu for each minisite, that takes care of updating it as soon as the respective minisite group changes. Here is one of the implemented hooks:

<?php
function atrium_minisite_nodeapi(&$node, $op, $arg = 0) {
 
  if (isset(
$node->spaces_preset_og) &&
     
atrium_minisite_is_minisite_preset($node->spaces_preset_og)) {
    if (
in_array($op, array('insert', 'update', 'delete'))) {
     
$menu = array();
     
$menu['title'] = $node->title;
     
$menu['menu_name'] = atrium_minisite_get_menu_name($node);
     
$menu['description'] = $node->og_description;
     
atrium_minisite_menu_api($op, $menu);
     
      if (
$op == 'insert') {
       
module_invoke_all('atrium_minisite_default_content', $node, $menu);
      }
    }
  } 
}
?>

As you can notice, our minisite feature exposes an atrium_minisite_default_content() hook which allows other modules to provide default content once a new minisite is created (e.g. "About" and "Contact" pages, etc...). Shipping each new minisite with default content allows the editor to start filling up the site straight away without the need to recreate again and again the same content structure.

To make our minisite menu group-aware, we implement hook_block() in atrium_minisites.module. The implementation below relies on a couple of helper functions defined elsewhere.

<?php
function atrium_minisite_block($op = 'list', $delta = NULL, $edit = NULL) {
 
 
$blocks = array();
  if (
$op == 'list') {
   
$blocks['primary-navigation']['info'] = t('Minisite: Primary navigation');
   
$blocks['primary-navigation']['cache'] = BLOCK_NO_CACHE;

   
$blocks['secondary-navigation']['info'] = t('Minisite: Secondary navigation');
   
$blocks['secondary-navigation']['cache'] = BLOCK_NO_CACHE;

   
$blocks['full-navigation']['info'] = t('Minisite: Full navigation');
   
$blocks['full-navigation']['cache'] = BLOCK_NO_CACHE;
  }
  if (
$op == 'view') {
    if (
atrium_minisite_is_minisite_space()) {
     
$config = atrium_minisite_get_menu_block_config($delta);
      if (
$delta == 'secondary-navigation' || $delta == 'full-navigation') {
       
$config['level'] = 2;       
       
$config['expanded'] = 1;
       
$config['depth'] = 0;
      }
      if (
$delta == 'full-navigation') {
       
$config['level'] = 1;       
      }
     
$blocks = menu_tree_build($config);
      unset(
$blocks['subject']);
    }
  }
  return
$blocks;
}
?>

This block is then specified as a context reaction, so that site visitors will see a self-contained navigation when browsing the minisite.

Making minisites themeable

Each minisite can be assigned a different theme. To do so from a convenient interface, we implement hook_form_alter() in atrium_minisite.module to give the possibility to select a theme for the given minisite. Again, we omit some helper functions for brevity.

<?php
/**
* Implementation of hook_form_alter()
*/
function atrium_minisite_form_alter(&$form, &$form_state, $form_id) {
 
  if (isset(
$form['#node']) && $form_id == $form['#node']->type .'_node_form') {
   
$node = $form['#node'];   
   
    if (
og_is_group_type($node->type)) {
     
module_load_include('inc', 'system', 'system.admin');     
     
atrium_minisite_theme_form($form);
    }
   
    if (
atrium_minisite_is_minisite_space()) {
      if (
$node->type == 'page') {
       
$space = spaces_get_space();
       
$conf['menu_default_node_menu'] = atrium_minisite_get_menu_name($space->group);
       
$menu_name = atrium_minisite_get_menu_name($space->group);
       
$menu = array($menu_name => $space->group->title);
       
$form['menu']['parent']['#options'] = menu_parent_options($menu, $item);
      }
    }
  }
}
?>

We can now choose the best theme for our minisite directly on the creation page:

minisite-theme.jpg

Serving minisites on different domains

Each Open Atrium group gets its own URL path component; in our case the minisite will be reachable at something like http://alfapuentes.org/conference/. With a quick Persistent URL customization we can actually set the URL rewriting to be per domain, allowing our minisite to have its own domain. This can be achieved by:

  1. Enabling the "Domain" URL modification type from admin/settings/purl/types;
  2. Assigning to "Group space" the new modifier type on admin/settings/purl;
  3. Adding a custom URL each time we are going to create a minisite group

By taking advantage of the Persistent URL domain rewriting we can really make the new minisite look completely independent from the underlying Open Atrium platform:

minisite-url.png

The techniques shown here are covered in detail in our trainings; if interested, contact us for more information.

Comments

Comments

Tyler
28 Nov 2011

I take it that's a custom theme you're using? I really liked this tutorial, and plan on using it in the very near future. Awesome write-up!

I take it that's a custom theme you're using? I really liked this tutorial, and plan on using it in the very near future. Awesome write-up!

Tyler, 28 Nov 2011

I take it that's a custom theme you're using? I really liked this tutorial, and plan on using it in the very near future. Awesome write-up!

Tyler, 28 Nov 2011
Andrea Pescetti
28 Nov 2011

Yes, the theme shown in the Alfa Puentes screenshots is a custom Open Atrium theme developed by Nuvole for that project.

Yes, the theme shown in the Alfa Puentes screenshots is a custom Open Atrium theme developed by Nuvole for that project.

Andrea Pescetti, 28 Nov 2011

Yes, the theme shown in the Alfa Puentes screenshots is a custom Open Atrium theme developed by Nuvole for that project.

Andrea Pescetti, 28 Nov 2011
btopro
28 Nov 2011

Very informative, I wouldn't have thought to tweak Atrium in this way to accomplish this. You might want to check out these projects that I wrote to try and make course sites in elms which seem similar in architecture --

Context Variable + Spaces Theme -- http://drupal.org/project/context_var & http://drupal.org/project/spaces_theme

These can allow you to provide site users even further flexibility in terms of setting properties like theme logo property and Primary links (as well as theme) per space. Should work in atrium as well if you add a link to /theme

Workflow Purl Integration -- http://drupal.org/project/workflow_purl - This lets PURL act more like pathauto via workflow module. Might be overkill but probably some code you can rip from it. I've found purl is great from dev perspective but poor from explaining the implication to end-users.

Very informative, I wouldn't have thought to tweak Atrium in this way to accomplish this. You might want to check out these projects that I wrote to try and make course sites in elms which seem similar in architecture --

Context Variable + Spaces Theme -- http://drupal.org/project/context_var & http://drupal.org/project/spaces_theme

These can allow you to provide site users even further flexibility in terms of setting properties like theme logo property and Primary links (as well as theme) per space. Should work in atrium as well if you add a link to /theme

Workflow Purl Integration -- http://drupal.org/project/workflow_purl - This lets PURL act more like pathauto via workflow module. Might be overkill but probably some code you can rip from it. I've found purl is great from dev perspective but poor from explaining the implication to end-users.

btopro, 28 Nov 2011

Very informative, I wouldn't have thought to tweak Atrium in this way to accomplish this. You might want to check out these projects that I wrote to try and make course sites in elms which seem similar in architecture --

Context Variable + Spaces Theme -- http://drupal.org/project/context_var & http://drupal.org/project/spaces_theme

These can allow you to provide site users even further flexibility in terms of setting properties like theme logo property and Primary links (as well as theme) per space. Should work in atrium as well if you add a link to /theme

Workflow Purl Integration -- http://drupal.org/project/workflow_purl - This lets PURL act more like pathauto via workflow module. Might be overkill but probably some code you can rip from it. I've found purl is great from dev perspective but poor from explaining the implication to end-users.

btopro, 28 Nov 2011
Mike
3 Feb 2012

very nice...why don't integrate the theme too, and how/when install it?...thx

very nice...why don't integrate the theme too, and how/when install it?...thx

Mike, 3 Feb 2012

very nice...why don't integrate the theme too, and how/when install it?...thx

Mike, 3 Feb 2012
Mike
3 Feb 2012

not "when"...where..:)

not "when"...where..:)

Mike, 3 Feb 2012

not "when"...where..:)

Mike, 3 Feb 2012
Anonymous
12 Feb 2012

Guys, thanks for sharing these tutorials - its so good to see someone pushing the boundaries of what Open Atrium can do and passing on the info for other Drupal developers to learn from . Since development seed left the Drupal scene, Ive been an avid follower of this blog for help with Atrium and features based development practices - keep up the good work.

Guys, thanks for sharing these tutorials - its so good to see someone pushing the boundaries of what Open Atrium can do and passing on the info for other Drupal developers to learn from . Since development seed left the Drupal scene, Ive been an avid follower of this blog for help with Atrium and features based development practices - keep up the good work.

Anonymous, 12 Feb 2012

Guys, thanks for sharing these tutorials - its so good to see someone pushing the boundaries of what Open Atrium can do and passing on the info for other Drupal developers to learn from . Since development seed left the Drupal scene, Ive been an avid follower of this blog for help with Atrium and features based development practices - keep up the good work.

Anonymous, 12 Feb 2012
gibbo
10 Mar 2012

This is exactly what I want to do but i cant figure out how to get the first bit working without hacking the core (Which Im told is bad). I also get the error atrium_minisite_is_minisite_preset() undefinded function in my custom module, I apologise as this is not a help forum but would appreciate some assistance as getting this working would be amazing

Any chance a bit more of a minisites for dummies for people like myself who are very much still learning

Thanks

This is exactly what I want to do but i cant figure out how to get the first bit working without hacking the core (Which Im told is bad). I also get the error atrium_minisite_is_minisite_preset() undefinded function in my custom module, I apologise as this is not a help forum but would appreciate some assistance as getting this working would be amazing

Any chance a bit more of a minisites for dummies for people like myself who are very much still learning

Thanks

gibbo, 10 Mar 2012

This is exactly what I want to do but i cant figure out how to get the first bit working without hacking the core (Which Im told is bad). I also get the error atrium_minisite_is_minisite_preset() undefinded function in my custom module, I apologise as this is not a help forum but would appreciate some assistance as getting this working would be amazing

Any chance a bit more of a minisites for dummies for people like myself who are very much still learning

Thanks

gibbo, 10 Mar 2012
Andrea Pescetti
11 Mar 2012

Indeed, this introduction is mostly for experienced developers and, as written in the post, we are omitting several helper functions here since the aim is to explain the general architecture of the code. This is a rather advanced topic, unfortunately!

Indeed, this introduction is mostly for experienced developers and, as written in the post, we are omitting several helper functions here since the aim is to explain the general architecture of the code. This is a rather advanced topic, unfortunately!

Andrea Pescetti, 11 Mar 2012

Indeed, this introduction is mostly for experienced developers and, as written in the post, we are omitting several helper functions here since the aim is to explain the general architecture of the code. This is a rather advanced topic, unfortunately!

Andrea Pescetti, 11 Mar 2012
Anonymous
6 May 2012

Hello, I have to open atrium sites for bottom up initiatives running and we need a public face. I´m a newbie in open atrium and don´t check where I have to change all the code you posted. Is there anywhere a more detailed description, who to develop the minisite?

best Nora

Hello, I have to open atrium sites for bottom up initiatives running and we need a public face. I´m a newbie in open atrium and don´t check where I have to change all the code you posted. Is there anywhere a more detailed description, who to develop the minisite?

best Nora

Anonymous, 6 May 2012

Hello, I have to open atrium sites for bottom up initiatives running and we need a public face. I´m a newbie in open atrium and don´t check where I have to change all the code you posted. Is there anywhere a more detailed description, who to develop the minisite?

best Nora

Anonymous, 6 May 2012
Andrea Pescetti
6 May 2012

As I wrote above, this introduction is mostly for experienced developers and the aim is to explain the general architecture of the code. This is a rather advanced topic, and a starting point would be to study the Spaces module: http://drupal.org/project/spaces

As I wrote above, this introduction is mostly for experienced developers and the aim is to explain the general architecture of the code. This is a rather advanced topic, and a starting point would be to study the Spaces module: http://drupal.org/project/spaces

Andrea Pescetti, 6 May 2012

As I wrote above, this introduction is mostly for experienced developers and the aim is to explain the general architecture of the code. This is a rather advanced topic, and a starting point would be to study the Spaces module: http://drupal.org/project/spaces

Andrea Pescetti, 6 May 2012
gibbo
12 Mar 2012

Ok, thanks for the reply, I have now managed to get as far as getting the additional group type working (i.e. the first bit) but getting public facing sites is still a bit beyond me at the moment, I have however improved my knowledge a great deal with the help of this post so thankyou and I will be watching for future entries.

If you can point me at any other tutorials that may assist id appreciate it

Many Thanks

gibbo

Ok, thanks for the reply, I have now managed to get as far as getting the additional group type working (i.e. the first bit) but getting public facing sites is still a bit beyond me at the moment, I have however improved my knowledge a great deal with the help of this post so thankyou and I will be watching for future entries.

If you can point me at any other tutorials that may assist id appreciate it

Many Thanks

gibbo

gibbo, 12 Mar 2012

Ok, thanks for the reply, I have now managed to get as far as getting the additional group type working (i.e. the first bit) but getting public facing sites is still a bit beyond me at the moment, I have however improved my knowledge a great deal with the help of this post so thankyou and I will be watching for future entries.

If you can point me at any other tutorials that may assist id appreciate it

Many Thanks

gibbo

gibbo, 12 Mar 2012
John Makelainen
12 Feb 2013

Hi

Your minisite system sounds quite neat.

Can it be used so, that there is one minisite that has a public html form that posts all the data to other groups case tracker. Kinda like open bug form, but where all the conversations about the bug is just for the developer groups eyes?

Hi

Your minisite system sounds quite neat.

Can it be used so, that there is one minisite that has a public html form that posts all the data to other groups case tracker. Kinda like open bug form, but where all the conversations about the bug is just for the developer groups eyes?

John Makelainen, 12 Feb 2013

Hi

Your minisite system sounds quite neat.

Can it be used so, that there is one minisite that has a public html form that posts all the data to other groups case tracker. Kinda like open bug form, but where all the conversations about the bug is just for the developer groups eyes?

John Makelainen, 12 Feb 2013
Andrea Pescetti
17 Feb 2013

You can do everything by programming properly, but the minisite addresses a different concept, i.e., providing facilities for creating and managing simple public spaces. This is quite independent from what you need in your context, even though the two could likely work together.

You can do everything by programming properly, but the minisite addresses a different concept, i.e., providing facilities for creating and managing simple public spaces. This is quite independent from what you need in your context, even though the two could likely work together.

Andrea Pescetti, 17 Feb 2013

You can do everything by programming properly, but the minisite addresses a different concept, i.e., providing facilities for creating and managing simple public spaces. This is quite independent from what you need in your context, even though the two could likely work together.

Andrea Pescetti, 17 Feb 2013
Cner
24 Apr 2013

I read the blogs you guys host on Open Atrium and it is obvious you are very skilled with it.

What puzzles me greatly is that you are not releasing commercial modules that add features like mini-sites to Open Atrium .. I bet you many folks (myself included) will gladly pay for it. The fact that such a useful solution is not being sold openly by you is one of the things that bothers me about the drupal eco-system (which I think is not effective enough) .. Wordpress is such a puny system but it is running rings round drupal on market share .. and this is the main reason why.

I mean if you put a reasonable price on it, you will make predictably great sales while helping Open Atrium, and Drupal at large. You can even guarantee that you protect your primary client type (bigger organizations) by releasing a basic variant of what you would normally code for your bigger clients. Everyone would be a winner.

How about that .. eh ?

I read the blogs you guys host on Open Atrium and it is obvious you are very skilled with it.

What puzzles me greatly is that you are not releasing commercial modules that add features like mini-sites to Open Atrium .. I bet you many folks (myself included) will gladly pay for it. The fact that such a useful solution is not being sold openly by you is one of the things that bothers me about the drupal eco-system (which I think is not effective enough) .. Wordpress is such a puny system but it is running rings round drupal on market share .. and this is the main reason why.

I mean if you put a reasonable price on it, you will make predictably great sales while helping Open Atrium, and Drupal at large. You can even guarantee that you protect your primary client type (bigger organizations) by releasing a basic variant of what you would normally code for your bigger clients. Everyone would be a winner.

How about that .. eh ?

Cner, 24 Apr 2013

I read the blogs you guys host on Open Atrium and it is obvious you are very skilled with it.

What puzzles me greatly is that you are not releasing commercial modules that add features like mini-sites to Open Atrium .. I bet you many folks (myself included) will gladly pay for it. The fact that such a useful solution is not being sold openly by you is one of the things that bothers me about the drupal eco-system (which I think is not effective enough) .. Wordpress is such a puny system but it is running rings round drupal on market share .. and this is the main reason why.

I mean if you put a reasonable price on it, you will make predictably great sales while helping Open Atrium, and Drupal at large. You can even guarantee that you protect your primary client type (bigger organizations) by releasing a basic variant of what you would normally code for your bigger clients. Everyone would be a winner.

How about that .. eh ?

Cner, 24 Apr 2013
Andrea Pescetti
5 May 2013

The current Open Atrium (1.x) architecture does not always allow to turn a nice feature into a plug-and-play "app" that will run on just about any Open Atrium system. So we'd rather get paid for consultancies rather than adopting a "paid download" model.

Open Atrium 2.x, instead, will be more focused on the concept of apps that will "just run" and, when released, if may offer better opportunities to those advocating a model like the one you describe.

The current Open Atrium (1.x) architecture does not always allow to turn a nice feature into a plug-and-play "app" that will run on just about any Open Atrium system. So we'd rather get paid for consultancies rather than adopting a "paid download" model.

Open Atrium 2.x, instead, will be more focused on the concept of apps that will "just run" and, when released, if may offer better opportunities to those advocating a model like the one you describe.

Andrea Pescetti, 5 May 2013

The current Open Atrium (1.x) architecture does not always allow to turn a nice feature into a plug-and-play "app" that will run on just about any Open Atrium system. So we'd rather get paid for consultancies rather than adopting a "paid download" model.

Open Atrium 2.x, instead, will be more focused on the concept of apps that will "just run" and, when released, if may offer better opportunities to those advocating a model like the one you describe.

Andrea Pescetti, 5 May 2013
Adam
4 Sep 2013

Hi!

I am a starter in drupal and Open Atrium, and I miss some important instructions like where to put the code in the "Making minisites self-contained: menus and blocks" section, and file names and directories. Maybe it is a noobie question, but is it possible to have those files in a zip to see ?

Thanks for the help!

Hi!

I am a starter in drupal and Open Atrium, and I miss some important instructions like where to put the code in the "Making minisites self-contained: menus and blocks" section, and file names and directories. Maybe it is a noobie question, but is it possible to have those files in a zip to see ?

Thanks for the help!

Adam, 4 Sep 2013

Hi!

I am a starter in drupal and Open Atrium, and I miss some important instructions like where to put the code in the "Making minisites self-contained: menus and blocks" section, and file names and directories. Maybe it is a noobie question, but is it possible to have those files in a zip to see ?

Thanks for the help!

Adam, 4 Sep 2013
Andrea Pescetti
5 Sep 2013

This post is for reasonably experienced developers who know how to write Drupal modules: we implement hooks, and this is done in filename.module files or included files. You can find more at https://api.drupal.org/api/drupal/includes!module.inc/group/hooks/6 (Open Atrium 1 is based on Drupal 6), but explaining that is beyond the scope of this post.

As for the code, these are snippets taken from a bigger project and we can't isolate them in a way that will work stand-alone, sorry.

This post is for reasonably experienced developers who know how to write Drupal modules: we implement hooks, and this is done in filename.module files or included files. You can find more at https://api.drupal.org/api/drupal/includes!module.inc/group/hooks/6 (Open Atrium 1 is based on Drupal 6), but explaining that is beyond the scope of this post.

As for the code, these are snippets taken from a bigger project and we can't isolate them in a way that will work stand-alone, sorry.

Andrea Pescetti, 5 Sep 2013

This post is for reasonably experienced developers who know how to write Drupal modules: we implement hooks, and this is done in filename.module files or included files. You can find more at https://api.drupal.org/api/drupal/includes!module.inc/group/hooks/6 (Open Atrium 1 is based on Drupal 6), but explaining that is beyond the scope of this post.

As for the code, these are snippets taken from a bigger project and we can't isolate them in a way that will work stand-alone, sorry.

Andrea Pescetti, 5 Sep 2013
Andrea Pescetti
10 Sep 2014

Comments are closed. If you need custom development on Open Atrium feel free to contact us through the contact form on this site.

Comments are closed. If you need custom development on Open Atrium feel free to contact us through the contact form on this site.

Andrea Pescetti, 10 Sep 2014

Comments are closed. If you need custom development on Open Atrium feel free to contact us through the contact form on this site.

Andrea Pescetti, 10 Sep 2014

Get your project started today!

Contact us