This project is not covered by Drupal’s security advisory policy.

Layouts is no longer supported. Drupal 8 will probably support a similar function in core. For layouts in your site in Drupal 7, try Display Suite or Panels

Layouts is an API for creating and reusing layouts in HTML. It adds an extra layer of configuration between content and templating functions.

Layouts 1.x
Layouts 1.x is a proof of concept only, however it is functional and in use on one production site. It allows you to

  • define a layout through its API
  • retrieve a layout in code
  • assign content to layout regions
  • render a layout

Layout uses the theme system to render layout templates, however not all theme properties are supported.


Get a list of all available layouts


Get information about a specific layout


Define one or more layouts


Define one or more layouts to be made available to other modules via the Layouts API.

Here is the example from Layouts, which defines a default, single column layout, rendered using the template 'default_layout.tpl.php' ...

function layouts_define_layouts(){
  return array(
    'default' => array(
      '#title' => t('Default'),
      '#name' => 'default',
      '#category' => '',
      '#icon' => '',
      '#theme' => array(
        'layouts_default_layout' => array(
          'arguments' => array('regions' => array()),
          'path' => 'theme',
          'template' => 'default_layout'
      '#regions' => array(
        'content' => t('Content'),

Create a new Layout object

$my_layout = layouts_load($name, $module = NULL);

This expects two parameters, the name of the layout to retrieve, and if that layout is provided by a third-party (e.g. Panels), the module name. This second parameter currently has no effect, but if provided will, in future, trigger Layouts to return the original Layout definition, rather than the normalised Layout definition.

Add content to a layout region

$my_layout->content($layout_region_name, $my_content);

Assemble the layout for rendering


Render (or return) the fully-rendered layout

echo $my_layout->render();

Usage example

The following example creates a new layout using the layout template 'layout_foo', adds content to its regions, and renders it.

    $layout = layouts_load('layout_foo');
    $layout->content('header', 'This is my header');
    $layout->content('right', 'This is the right column');
    $layout->content('left', 'This is the left column')


    echo $layout->render;

Project Information

  • Maintenance status: Unsupported
  • Development status: Obsolete
  • Downloads: 487
  • Last modified: 27 November 2014
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.