Comparison of Drupal 7 Block Building Modules

Blocks within Drupal 7 is a powerful  method of displaying supporting content on Drupal sites.  Blocks can be simple output with just series of links or can contain highly processed information, or partial content of a node.

There are several modules that support the creation of blocks.  They are each quite different.  Here is a comparison of the major features of each to help you decide.

Drupal
Modules ---->>
Blocks (core) Boxes Custom Page Codit Blocks
Blocks created in: Admin Admin Admin and tpl tpl and callback function
[100% code]
Block Editing Admin Admin Code Code
Visibility
  • Roles
  • Pages (paths)
  • Content type

Controlled by the placing agent

  • Roles
  • Pages (paths)
  • Content type

Controlled by the placing agent

  • Roles
  • Pages (paths)
  • Content type

Controlled by the placing agent

  • Roles
  • Pages (paths)
  • Content type
  • User
  • Field(s)
  • Taxonomy

Mashup of any of the above.

Caching Default Drupal Default Drupal Default Drupal

a) per user
b) per role
c) per path (page) or partial path (pages)
d) per field value(s)
e) sitewide
f) taxonomy or terms

Or any mashup of a-f.

PHP PHP in db is possible PHP in db is possible In tpl In tpl and or callback function
Output code and html in a text field code and html in a text field tpl tpl
Exportable Yes
Using Features module

Yes
As a Ctools Exportable or using
Features module

Yes
Using Features module and copying the tpl
Copy block specific directory and paste it.
Drush Support No No No Yes
Pros
  • Easy to add simple static blocks
  • Easy to add simple static blocks.
  • Easy for editor to modify contents.
  • PHP not in db
  • tpl can be under code version control.
  • Can make pages too.
  • More performant for blocks that are process intensive.
  • Most flexible.
Cons
  • php in db
  • php in db
  • Need both admin and file access
  • Can only be built and edited by developers.
         

 

Drupal 7 Block building

There are 4 modules that offer block building solutions. Here they are listed in order from simple to robust.

  1. Block module - The block admin of core Drupal allows for the creation of custom blocks through admin fields only. The blocks have no supporting code unless exported as a Feature. Blocks created through the block admin, get numerical ids, which makes theme-ing live and dev problematic.
  2. Custom Page module - This module allows for the creation of custom pages and custom blocks by creating a unique ID and then using that to create a tpl that will control the output of the page or block. This works well, but upon deploying it means pushing code AND admin work.
  3. Boxes module - This module also allows for the creation of blocks through admin and offers the ability of being able to edit the content of the block directly on the page for any user that is properly permissioned. This module is similar to the core block admin in that there is no tpl and no code, but it does support exportables. It is a better choice than the core block admin. And if you need simple admin editable blocks it is the best choice. When you start thinking about putting php in the text field though, it is time to consider Custom Page or Codit: Blocks.
  4. Codit: Blocks is more robust in many ways, offering developers who code a lot more control over their blocks including caching, php processing for heavy lifting and safety in a system that is 100% in code.

Here is a list of the main differences between Codit: Blocks the other solutions:

  1. Code - Codit: Blocks are 100% code based. The only admin is whatever tool you use to place them (block admin, Context, Panels). Boxes or the Block module are nearly entirely admin based and are the antithesis of Codit: Blocks.
  2. Caching - Codit: Blocks offers simple yet highly capable caching ranging from sitewide to per user or per page, or even per-user-per-subpath on a block-by-block basis. Boxes and Custom Page offer no additional caching other than standard Drupal anonymous page caching.
  3. Individual Block User Access - Codit: Blocks have easy to define access based on role, user or any other custom criteria. Boxes and Custom Page offer none by themselves. All the blocks they create are publicly visible to any user unless controlled by context or panels.
  4. Editing Blocks - Codit: Blocks or Custom Page = Anyone with developer access. Boxes = anyone with account privileges. There are pros and cons to each method.
  5. Heavy PHP Processing - In Codit: Blocks, php processing resides safe from collisions in an anonymous callback function that can pass items to the tpl. With Boxes it resides in the DB (plugins to this may offer some additional options). With Custom Page, any heavy php needs to reside in the tpl which works in a pinch but is not an ideal design.
  6. Output - Codit: Blocks and Custom Page use a block specific tpl.php for each block that can be moved to theme if needed to have different output on sites with multiple themes. With Boxes it is all by code and html in a text field.

Drupal 7 Blocks Summary

If you are a developer, it is easy to favor Codit: Blocks. If you or your client needs an admin based system then Boxes or Custom Page is a better choice.

Placement Agents

Once  a block is built using any of the modules above, the block needs to be placed on the page through a placement agent like

section: