Earlier this week I added the Boxes module, which provides custom blocks that play nicely with Spaces and Ctools, to Drupal.org. I initially wrote the module for recent work we did on the World Bank’s Open Atrium-based intranet, and at first I wasn’t sure if it would be something that we’d want to maintain and release on Drupal.org, as it seemed rather project specific. However after using it on this project, it became apparent that we’ll want to use the Boxes module on many projects and that the module could play a large role in making Open Atrium stronger out of the box.
The Boxes module has two primary purposes - to provide Ctools style exportable blocks and to integrate with the new 3.x branch of Spaces. Here is a brief screencast demonstrating a small part of what the module does.
The core block module provides a functionality for “Custom blocks”, also occasionally called “Boxes” in the module’s code, and it’s fairly common for us to want to ship some blocks that use this functionality with a site launch or update. Before the Boxes module, we had two options on how to do this - we could either write an install (or update) script that creates these boxes, or we could hardcode the boxes in a custom module. An issue with the first option is that it’s not possible to predict what the ID of the box will be, as it’s generated from the sequential ID of the update, and this makes it hard to reference elsewhere in the site. And with the second option, the client needs to be a programmer to make even the smallest change to the text in the block. In reality, the default, normal, overridden model that modules like Views support is much closer to the functionality we want for blocks.
With the Boxes module, a site builder can package a block with a feature built for the site. The visibility of the block is controlled via a context that is also a part of the same feature. When the client needs to change the contents of this block, they can do so directly, without jumping through hoops or editing code.
As Boxes was built as part of an Open Atrium deployment, it was natural that we’d want to be able to customize these blocks or add new ones for each group on the site. Open Atrium let’s you create any number of mini-sites (which we generally call groups as they’re made using the Organic Groups module) that each have slightly different configurations. Boxes has Spaces module integration, which allows you to customize existing blocks for a specific group or create entirely new blocks that can only been seen and accessed in the space where they were created.