Flexinode Module: Print flexinodes in multiple columns, pages
PLEASE NOTE These snippets are user submitted. Use at your own risk. For users who have setup Drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
This snippet calls up all content from type flexinode-2, and then styles it into as many columns as you want. It doesn't have to be a flexinode - you could summon blog nodes or book pages. Just plunk in whatever node type you prefer into $node_type.
You can change the number of columns by setting $objects_per_row to your preference, or change the $objects_per_page to tell Drupal how many results to return with for each page.
Lastly, $flexwidth is just an optional thing that I needed for my layout. I've left it set to 100% for convenience.
<?php
//node type in question
$node_type = "flexinode-2";
//number of columns
$objects_per_row = 2;
//number of results per page
$objects_per_page = 10;
//optional table width setting
$flexwidth = '100%';
print '<TABLE width="' . $flexwidth . '" cellpadding=0 cellspacing=0><TR>';
$result = pager_query("SELECT n.nid, n.created, n.title FROM {node} n WHERE n.type = '$node_type' ORDER BY title", $objects_per_page);
$i = 0;
while ($node = db_fetch_object($result)) {
print '<TD valign=top>';
print node_view(node_load(array('nid' => $node->nid)), 1);
print '</TD>';
$i++;
if ($i == $objects_per_row)
{
print '</TR><TR>';
$i = 0;
}
}
print '</TD></TR></TABLE>';
//summons the pager at the bottom
print '<TABLE width="' . $flexwidth . '" colspan="' . $objects_per_row . '">
<TR><TD>'. theme('pager') .'</TD></TR>
</TABLE>';
?>