Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
These snippets allow you to show nodes in two columns on any teaser listing page. It works for PHPtemplate
in template.php add:
function _exampletheme_nodebreak($node) {
static $count;
if ($node->sticky) {
return TRUE;
}
else {
$count = is_int($count) ? $count : 1;
$return = ($count % 2) ? FALSE : TRUE;
$count++;
//dprint_r('WOOT');
return $return;
}
}
in node.tpl.php add to the end (after all the node content)
<?php if (($page == 0) && _exampletheme_nodebreak($node)): ?>
<br class="clear" />
<?php endif; ?>
And add to your style.css, a something like:
#contentcenter .node.teaser {
float: left;
width: 223px; //for fluid layout use 50%
margin-left: 20px; //for fluid layout set to 0;
padding: 0;
}
Note that you can play aroun with the values and make it a three column mayout without much hassle too.
Comments
it IS working, but
It works, but you'll have to adjust the css, in order to make it work with your theme. For Garland (the default theme in 5) it is something like:
better solution
The disadvantage of this method is the gaps that it produces. (When, on the same row, a short teaser on the left side is paired with a long teaser on the right side, there will be a gap under the text on the left side, because the next row will start under the longest article).
It's probably better and easier to use the views module with the views bonus pack (http://drupal.org/project/views_bonus) and the frontpage module. It allows you to create a node with a view (views module) that can be divided into columns with the help of so called panels (views bonus pack). This page can be turned into the frontpage (frontpage module).