By Sam308 on
How would you display all the forum topics within a particular forum container?
If the following PHP code will display all the toipics within a particular forum (forum #17 in this example), how would you modify the code to display all the forum topics within a particular forum container?
<?php
$listlength="10";
$forum_term_id = 17;
$sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND t.tid = $forum_term_id AND n.type='forum' ORDER BY l.last_comment_timestamp DESC";
$sql = db_rewrite_sql($sql);
$content = node_title_list(db_query_range($sql, 0, $listlength), t('Active forum topics:'));
if ($content) {
$content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>';
}
print $content;
?>
For example, I would like to display all the forum topics under Container 1. Ideally, it would be nice to display the "container - forum - topic" hierarchy if possible.
Container 1
- Forum 1
- Topic 1
- Topic 2
- Forum 2
- Topic 1
- Topic 2
- Forum 3
- Topic 1
- Topic 2
- Forum 4
- Topic 1
- Topic 2
Container 2
- Forum 5
- Topic 1
- Topic 2
- Forum 6
- Topic 1
- Topic 2
- Forum 7
- Topic 1
- Topic 2
- Forum 8
- Topic 1
- Topic 2
Thanks in advance,
Sam