layout_block module

Updated: latest module version, improved module design

I put together a module for a theme that I'm working on which gives more flexibility to the layout of blocks. The theme itself is a flexible multi column layout, so the blocks can be defined to 1-5 columns. Eventually I'll start doing some hooks for other content types as well so that an entire theme can be multi column.

The module installs easily. Customization relies on CSS and images. Basically this module gives the following three options to blocks:

1) control how many columns a block takes up
2) control what icon goes with a block
3) control what background a block has

It assumes that you have these things in place. It comes with some css and a set of icons. It does allow you to set a path to a directory of icons and then it will make those available to the admin.

You can add this blocks programatic aspects to block.tpl.php with this code:


$cols = variable_get('layout_block-'. $block->module .'_'. $block->delta, '1');

$icon = variable_get('layout_block-'. $block->module .'_'. $block->delta . '_icon', 'icon-member.gif');

$background = variable_get('layout_block-'. $block->module .'_'. $block->delta . '_background', 'solid_white');

In the module itself, I have an array of options for the block classes. These are tied to the CSS file, so if you want to use different class names, you can modify these pieces.


$background_select = array(
'solid_white' => t('Solid white background'),
'gradient_1' => t('Light gradient'),
'gradient_2' => t('Medium gradient'),
'gradient_3' => t('Dark gradient'),
'solid_1' => t('Light solid'),
'solid_2' => t('Light med solid'),
'solid_3' => t('Medium solid'),
'solid_4' => t('Medium dark solid'),
'solid_5' => t('Dark solid')
);

This ends up building a class definition for blocks like this:


$block_class = "block_" . $background . "_" . $cols . "col";

My blocks look like this:

subject; ?>

content; ?>

The CSS for these blocks is not well abstracted yet, but here's an example:

/* solid 1, 1col */
.block_solid_1_1col {
background-image: url('pieces/block/middle/1-s1.gif');
background-position: top;
background-repeat: repeat-y;
margin-bottom: 9px;
margin-right: 9px;
width: 145px;
}

.block_solid_1_1col .block_header{
background-image: url('pieces/block/header/1-blockhead.gif');
}

.block_solid_1_1col .block_footer{
background-image: url('pieces/block/bottom/1-s1.gif');
}

Here's what the admin interface looks like:

Download the module

Hi, great site, and the

Hi, great site, and the layout block sonds nice. I downloaded the module you linked to but I didnt see the css and icons you mentioned. thought it may have been corrupted download, but however many times i tried downloading, still couldnt see those files. Thanks again for drupal tips and commentary!

I updated the module and it

I updated the module and it should be working fine now.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options