Topics

// maximum number of items to show:
$count = 1000;

$topics = db_query_range(db_rewrite_sql("SELECT n.nid, n.title
FROM {node} n
WHERE
n.status = 1 AND n.type like 'topic'
ORDER BY n.title ASC"),$node_id,0,$count);

$output = "";

$col = "l";

while ($node = db_fetch_object($topics)) {

if ($col=="l") {
$output .= "

";
} else {
$output .= "

";
}

$output .= "

";

if ($col=="r") {
$output .= "

";
$col = "l";
} else {
$col = "r";
}

}
print $output;
?>

     
";

$output .= "


" . $node->title . "

";

// get current "topic" node id
$topic_node_id = $node->nid;
// maximum number of items to show:
$topic_count = 10;
//items retreived
$topic_loop_count = 0;

$topicresult = db_query_range(db_rewrite_sql("SELECT n.nid, n.title
FROM {node} n
INNER JOIN {content_field_topics} topic ON n.nid = topic.nid
INNER JOIN {content_field_date_published} pubdate ON n.nid = pubdate.nid
WHERE topic.field_topics_nid = %s AND
n.status = 1
ORDER BY pubdate.field_date_published_value DESC"),$topic_node_id,0,$topic_count);

while ($topicnode = db_fetch_object($topicresult)) {
$topic_loop_count++;
$items[] = l($topicnode->title, 'node/'. $topicnode->nid);
}
$topicoutput = theme('item_list', $items);
$output .= $topicoutput;

$topicoutput = "";
mysql_free_result($topicresult);
$topicnode = "";
$items = "";

if ($topic_loop_count == $topic_count) {
$output .= "     More " . $node->title . " articles";
}

$output .= "

";

$output .= "