bbPress

Simple, fast, elegant

bbPress Plugin Browser »

Forum Last Poster (0.0.5)

Download

Version: 0.0.5

Last Updated: 2009-7-26

Requires bbPress Version: 0.8.2 or higher

Compatible up to: 0.9

Author Homepage »

Plugin Homepage »

Donate to this plugin »

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(1)

Your Rating

Author: _ck_

Adds forum_last_poster(), forum_time(), forum_last_post_link() and other functions to bbPress to mimic the topic tables' FRESHNESS column. Requires simple template edits.

High performance: uses only a single extra query regardless of the number of forums listed (when topics are on same page).


  1. _ck_

    Moderator

    You can see a demonstration of this plugin in action by looking at the forum list at the top of http://bbshowcase.org/forums/

    (notice the "Last Poster" column)

    The code used to make that column is:

    <td class="num"><?php echo '<a href="'.get_forum_last_post_link().'">'.get_forum_last_poster().'<small>'.get_forum_time().' ago</a></small>'; ?></td>
    Posted: 1 year ago #
  2. Is this stuff can be used to display gravatar of last poster? If so, how?

    Posted: 1 year ago #
  3. csseur3

    5 stars
    4 stars
    3 stars
    2 stars
    1 star

    Member

    if we can have the title of the last post, in wich last comment was made?

    and it is possible to add a function to truncate this, for the title wich are too big? :)

    great plugin ck! hum, i think is great if this plugin is in bbpress bu default :D

    bye,
    Fred

    Posted: 1 year ago #
  4. _ck_

    Moderator

    csseur3 you can take advantage of the function forum_last_topic_id() to fetch any info you'd like about the last topic in a forum.

    Here is an example of how to use it:
    topic_title(forum_last_topic_id());
    That will echo the last topic title to the screen.

    Or to store it and manipulate it further:

    $last_topic_title=get_topic_title(forum_last_topic_id());

    (you'll need to do some PHP to limit the length, like the substr function, see php.net)
    $last_topic_title=substr($last_topic_title,0,40);

    or you can fetch everything about the last topic:
    $last_topic=get_topic(forum_last_topic_id());
    and then you can determine things like how many posts it has:

    echo "Most recent topic has $last_topic->topic_posts posts";
    Posted: 1 year ago #
  5. _ck_

    Moderator

    Thion, you can fetch the gravatar through a little indirect code as I don't have a function in there yet to grab all the user's info.
    ie.

    $last_topic=get_topic(forum_last_topic_id());
    $last_topic_poster_id=$last_topic->topic_last_poster;
    $last_topic_poster_email=bb_get_user_email($last_topic_poster_id);

    then you use the email to get the gravatar:

    <img src="<?php echo "http://www.gravatar.com/avatar.php?gravatar_id=".md5($last_topic_poster_email); ?>">
    Posted: 1 year ago #
  6. Anonymous

    Unregistered

    And another thing.
    I have this line in my front-page.php
    <td class="num"><a href="<?php forum_last_post_link(); ?>"><?php forum_last_poster(); ?></a><br /><?php forum_time(); ?></td>
    And I have also this forum is category plugin.
    And the problem is that, I dont want this last poster to show if forum is catogory.
    Can you help me with this? I have been trying few things but I've failed.

    And this is the forum is category plugin: http://bbpress.org/plugins/topic/forum-is-category/

    Posted: 1 year ago #
  7. _ck_

    Moderator

    markok, you could try something like this:

    <td class="num"><?php if (!in_array($GLOBALS['forum']->forum_id, $GLOBALS['forums_that_are_categories'])) {
     ?><a href="<?php forum_last_post_link(); ?>"><?php forum_last_poster(); ?></a><?php } ?><br /><?php forum_time(); ?></td>
    Posted: 1 year ago #
  8. Anonymous

    Unregistered

    Thanks, that did the trick.

    Posted: 1 year ago #
  9. csseur3

    5 stars
    4 stars
    3 stars
    2 stars
    1 star

    Member

    hey ck,

    when a forum was empty, we see the first post's title (the 'your-first-topic' by default) in the column. So i think it is interestig to create a "error message" like "sorry, this forum is empty" :p

    bye

    Posted: 1 year ago #
  10. I'd like to use something like this to display (in the right-hand column as a plugin) the last 10 posts with links to display posts within the last 24, 48 etc hours....any suggestions? Thanks!

    Posted: 1 year ago #
  11. _ck_

    Moderator

    cocotrp it's very easy, see my instructions here:
    http://bbpress.org/forums/topic/heres-how-to-show-bbpress-info-inside-wordpress-without-full-integration

    Posted: 1 year ago #
  12. I am using the plugin for the front page of my wp installation...members have been requesting this as a sidebar for the forums home page and I've been struggling with getting it to work inside the forums. I think I wasn't very clear...I wanted to show this information on the sidebar of the forums home page.

    Posted: 1 year ago #
  13. _ck_

    Moderator

    Yes, the functions I show in that guide can be used inside bbPress too. You can adjust it to show posts instead of topics.

    Posted: 1 year ago #
  14. I have started with creating a simple forum list in the sidebar. I'm getting this error:

    Fatal error: Call to a member function on a non-object in /home/xxx/right-sidebar.php on line 18

    Line 18 is:

    $results=$wpdb->get_results($query);

    Posted: 1 year ago #
  15. amazing what happens when you read everything! Changed $wpdb to $bbdb and it works...thanks!

    Posted: 1 year ago #
  16. _ck_

    Moderator

    Sorry I forgot to mention that, I'm very distracted today.

    If you have any further questions about how to bring up posts, etc. please feel free to ask in that other topic (rather than here).

    Posted: 1 year ago #
  17. This works correctly for every forum except the default forum. No last topic poster is displayed for the default forum, incorrect post link and incorrect last post time. All other forums in the loop work perfectly.

    For the default forum I get a last post time of 39 years!

    Posted: 9 months ago #
  18. _ck_

    Moderator

    kineda, what version of bbPress are you using?

    Posted: 9 months ago #
  19. I hit some pretty big performance issues with this, 6 minute post times with a biggish DB (3732 topics, 23 forums, 106937 posts, 12205 users).

    I think the issue is on line 28 (SQL to select *every* row in topics) and line 31 where the code then loops over every topic.

    Posted: 8 months ago #

RSS feed for this topic

Add a Comment »

You must log in to post.

Code is Poetry.