Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display the latest discussions titles into a webpage

  • What if I want to show some of the latest discussions inside my site home page? Just titles (with links) would do. Is there any way one can grab them, perhaps as RSS, and display them into a page? I know, as an example, this is currently done for twitter posts. What about bbpress discussions?

Viewing 8 replies - 1 through 8 (of 8 total)
  • There’s the latest topics RSS feed at /rss/topics and the WordPress Latest Post plugin: http://bbpress.org/plugins/topic/wordpress-latest-post/, either of those help?


    Olaf Lederer
    Participant

    @finalwebsites

    why not using the RSS feed from some blog?

    They could surely be worth inspecting, if I only really knew anything about coding.

    :-)

    So, you mean that if I place this piece of php code [1] into any web page I’ll show a list of entries? I tried but it doesn’t seem to work at all.

    So, the idea of just swapping wordpress variables with bbpress ones is not enough.

    No. I’m afraid it would be beyond my skills.

    —-

    [1] http://bbpress.org/plugins/topic/wordpress-latest-post/

    Instead, that /rss/topics thing looks promising: if I only could find the source of that page, and throw away most of the code, just to keep the last 5 or so entries with no formatting, that would be more than enough.

    There is a rss.php file inside the bbpress folder, but there is too much code and I get lost into it.

    Ah the plugin is intended for WordPress installs only I’m afraid.

    A quick way of doing it:

    In your bbPress directory, make a file called javascript.php containing:

    <?php

    // Taken from index.php
    // Load everything up

    require('./bb-load.php');

    do_action( 'bb_index.php_pre_db' );

    $forums = bb_get_forums(); // Comment to hide forums
    if ( $topics = get_latest_topics( false, $page ) ) {
    bb_cache_last_posts( $topics );
    }

    bb_load_template( 'html_include.php' );

    ?>

    then in your template directory, make a file called html_include.php containing:

    <?php if ( $forums && $topics ) : ?>
    <table id="latest_discussions">
    <tr>
    <th><?php _e('Topic'); ?></th>
    <th><?php _e('Posts'); ?></th>
    <!-- <th><?php _e('Voices'); ?></th> -->
    <th><?php _e('Last Poster'); ?></th>
    <th><?php _e('Freshness'); ?></th>
    </tr>

    <?php foreach ( $topics as $topic ) : ?>
    <tr>
    <td><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>
    <td class="num"><?php topic_posts(); ?></td>
    <!-- <td class="num"><?php bb_topic_voices(); ?></td> -->
    <td class="num"><?php topic_last_poster(); ?></td>
    <td class="num"><a href="<?php topic_last_post_link(); ?>" title="<?php topic_time(array('format'=>'datetime')); ?>"><?php topic_time(); ?></a></td>
    </tr>
    <?php endforeach; // $topics loop ?>
    </table>
    <?php else : ?>
    No discussions.
    <?php endif; ?>

    and finally, in the page where you want to load the list, put something like:

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>$.get("javascript.php", { rand: Math.random() }, function(data){ document.getElementById('latest').innerHTML = data; } );</script>
    <div id="latest"></div>

    Old-fashioned way of loading the HTML in there and use a local copy of jQuery or whatever library you use, but that’s the general idea really.

    html_include.php is just a cut down version of front-page.php so you can edit it the same as any other template. javascript.php doesn’t load in stickies, but that’s just how I felt like doing things, it’s a cut down version of index.php so it’s easy enough to put back.

    Even more cut down version of html_include.php (so you really do just get a list):

    <?php if ( $forums && $topics ) : ?>
    <ul>
    <?php foreach ( $topics as $topic ) : ?>
    <li><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></li>
    <?php endforeach; // $topics loop ?>
    </ul>
    <?php else : ?>
    No discussions.
    <?php endif; ?>

    It’s probably easier to use a RSS parser to be honest, but I couldn’t find one that’d use a local RSS source rather than a remote one passed through a PHP script first, so meh.

    I got it!

    See here http://www.kirpi.it/rss2html/rss2html.php?XMLFILE=http://www.kirpi.it/r/rss/topics&TEMPLATE=sample-template.html&MAXITEMS=10

    You just download a folder [1] into your server and make a call with the proper parameters.

    Templates are trivial to edit.

    Looks the right thing for dummies like me :-)

    So, the raw problem is solved.

    Now let’s go bor a better solution, if there is any.

    I’ll try your code, kawauso, and let you know.

    —-

    [1] http://www.feedforall.com/free-php-script.htm

    Haha or that :P I work with a server that’s almost completely firewalled in most of the time, makes doing anything that easy impossible

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.