Two columns on pages with lists of nodes

Last modified: November 7, 2006 - 02:39

This javascript code can be placed in the footer (and the footer must be enabled). It will restyle the nodes so they're narrower, and float them left and right, down the page. I'm using it with the box_gray theme. The theme may affect the operation of this script.

The element ID in the second line may need to be changed for other themes. Do a View Source on the page, and see what ID is used in the HTML.

<script type="text/javascript"><!--
var content = document.getElementById("content-left");
var nodes = content.getElementsByTagName("div");
var nodeNodes = new Array();
for(i=j=0;i<nodes.length;i++)
{
   if (nodes[i].className=='node')
       nodeNodes[j++] = nodes[i];
}
if (nodeNodes.length > 1)
{
   for(i=0;i<nodeNodes.length;i++)
   {
      theNode = nodeNodes[i];
      theStyle = theNode.style;
if ( (i%2)==0 )
{
theStyle.cssFloat = theStyle.styleFloat = "left";
theStyle.width = "45%";
theStyle.clear = "both";
}
else
{
theStyle.cssFloat = theStyle.styleFloat = "right";
theStyle.width = "45%";
}
   }
}
// --></script>

 
 

Drupal is a registered trademark of Dries Buytaert.