Skip to:
Content
Pages
Categories
Search
Top
Bottom

Alter Loop for Paged Forum Pages?

  • I really like how this works on the front page:

    $forum_id = 1;

    $forum_one_topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC LIMIT 0,10")

    foreach($forum_one_topics as $topic) :

    ?>

    but would like to use this for the whole site. Is it possible to make this the logic of the entire site loop?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just for some more clarification – I would like my forum to show the most recent topics first – not the most active. Is there some easy way to set this up?

    I figured it out and wanted to share. This code goes at the top of my forums.php file (template).

    <?php
    $forum_id = 1;
    $limit = bb_get_option('page_topics');
    $offset = ($page-1)*$limit;
    $forum_one_topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id AND topic_status = 0 ORDER BY topic_id DESC LIMIT $limit OFFSET $offset")
    ?>

    My posts loop:

    <?php

    foreach($forum_one_topics as $topic) : $forum_one_topic_posts = get_thread( $topic->topic_id); ?>

    Works like a charm


    deadlyhifi
    Participant

    @tomdebruin

    $forum_one_topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id AND topic_status = 0 AND topic_sticky = 0 ORDER BY topic_id DESC LIMIT $limit OFFSET $offset");

    updated to leave out sticky posts from the second loop (added AND topic_sticky = 0 to query).

    If you leave out ‘$forum_id = 1;’ it will work on multiple forums.

    I’ve done this so that my front page summary shows latest active posts, but my specific forum pages list by topic order.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar