Drupal - Two column node list

|

Normally drupal node list is single column only. We can change number of columns for node list display. In this site nodes are displayed in 2 column.

This I did by hacking node.module. This can be done by CSS and at template level. I feel comfortable with coding, I hacked node.module. I am now progressing well in templates and css.
Here is the code for node.module(function node_page_default - line 2010) to achieve multi column node list.
------------------------

/*
//----G commented for two column list
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load($node->nid), 1);
}
*/
//----G TWO COLUMN View
$output = '<table class="twocolumnlist">';
$counter = 0;
while ($node = db_fetch_object($result)) {

if(!($counter % 2)){
$output .= '<tr><td valign="top" width="50%" class="twocolumn1">'.node_view(node_load($node->nid), 1).'</td>';
}else{
$output .= '<td valign="top" width="50%" class="twocolumn2">'.node_view(node_load($node->nid), 1).'</td></tr>';
}

$counter++;
}

$output .= '</tr></table>';

------

Chat Now


» gsee's Hypothesis | login to post comments


Submitted by WellingtonIII on Sun, 2007-05-20 19:45.

I cannot get this modification to work. It gives me an error message. My drupal version is 5.1

Could you be more specific as to what code to replace?

Thanks

Submitted by admin on Mon, 2007-05-21 11:53.

I worked two column mode in drupal version 4.7.x

This code snippet may work in all the versions. If you paste the error message you get, it will be more help full to study.

You need to hack the node.module file to implement two column node list in code. node module is available in module folder. If you still have problem, please mail me(through contact form in this website) , I will send my node.module to you. you can try out directly replacing the file.

Submitted by Publicidad en internet (not verified) on Sat, 2008-06-14 07:00.

You could also use the panels module. Easier and more configurable, because you can add single nodes, different styles, etc.

Submitted by Anonymous (not verified) on Wed, 2009-08-05 11:34.

Thank you, for your clear, concise and clean explanation, my head feels better already.



Click here to Receive Updates From this Blog