Skip to:
Content
Pages
Categories
Search
Top
Bottom

Last Post on Forums

  • @gerikg

    Member

    I want to put a new column called “Last Post” on the bottom section of the front-page.php.

    so it will be

    Forums

    Main Theme Topics Posts Last Post

    Installation — Getting it up and running -6,451 9,163 by GerikG on Thu Dec 10 2009 16:48:32

    I tried

    <small>by <?php topic_last_poster(); ?><br />on <a href="<?php topic_last_post_link(); ?>"><?php echo date("D M j Y G:i:s", strtotime($topic->topic_time)); ?></small>

    but that didn’t work.

Viewing 23 replies - 1 through 23 (of 23 total)
  • @gerikg

    Member

    anyone… am I under too unclear?

    @olympus

    Member

    I am afraid the topic_* fonctions only work in The Loop ( ® ) .

    @gerikg

    Member

    I got that, so what does work?

    @nightgunner5

    Member

    Add <?php $topic = $GLOBALS['topic'] = get_latest_topics( array( 'number' => 1, 'forum' => get_forum_id() ) ); ?> before the snippet you posted. (Untested, but I think it will work)

    @plutopsyche

    Member

    I tried the following:

    <?php $topic = $GLOBALS = get_latest_topics( array( ‘number’ => 1, ‘forum’ => get_forum_id() ) ); ?><?php topic_last_post_link(); ?>

    But all it returned was:

    http://bookclub.plutonica.net/topic/#post-

    Is there any documentation on the tags available with bbPress? I’ve tried searching this site and Google, but I can’t seem to turn up anything comprehensive.

    Thanks.

    @gerikg

    Member

    plutopsyche not yet, but they are going to work on it (codex) by 2010.

    Any other suggestions?

    @plutopsyche

    Member

    I’m still unclear as to why I shouldn’t be putting my custom template in /my-templates/ rather than /bb-templates/. It’s often said that you shouldn’t, but when I put it in /my-templates/ most of the tags stop working, like the one listed above. I still haven’t got it to work.

    The code to get topic titles and so forth don’t seem to work outside of the /bb-templates/ directory either?

    Thanks.

    @gerikg

    Member

    plutopsyche make sure my-template folder has a permission of 755.

    @plutopsyche

    Member

    Thanks, but I’ve already tried that, it still doesn’t seem to work. :/

    @nightgunner5

    Member

    Are you inside the loop when you use the snippet I gave you?

    @gerikg

    Member
    <tr<?php bb_forum_class(); ?>>
    <td><?php forum_icon(); ?> <?php bb_forum_pad( '<div class="nest">' ); ?><a href="<?php forum_link(); ?>"><b><?php forum_name(); ?></b></a><br /><?php forum_description( array( 'before' => '<small>', 'after' => '</small>' ) ); ?><?php bb_forum_pad( '</div>' ); ?></td>
    <td class="num"><?php forum_topics(); ?></td>
    <td class="num"><?php forum_posts(); ?></td>
    <td class="lastp"><?php $topic = $GLOBALS['topic'] = get_latest_topics( array( 'number' => 1, 'forum' => get_forum_id() ) ); ?><small>by <?php topic_last_poster(); ?><br />on <a href="<?php topic_last_post_link(); ?>"><?php echo date("D M j Y G:i:s", strtotime($topic->topic_time)); ?></small></a></td>
    </tr>

    results in

    by

    on Wed Dec 31 1969 19:00:00

    @nightgunner5

    Member

    Oh! I see the problem! (Or at least one of them)

    Try <?php $topic = $GLOBALS['topic'] = current( get_latest_topics( array( 'number' => 1, 'forum' => get_forum_id() ) ) ); ?>

    @gerikg

    Member

    okay looks like it works BUT I need an if statement because not all forums have topics in them.

    “Warning: current() [function.current]: Passed variable is not an array or object in”

    @buddha-trance

    Member

    I tried what Ben L. suggested and it works fine even with a forum with no topics (in which case there is no topic title shown because there is none, and it shows a view count of 0)

    I implemented it this way:

    <td class="num"><a href="<?php $topic = $GLOBALS['topic'] = current( get_latest_topics( array( 'number' => 1, 'forum' => get_forum_id() ) ) ); ?>"><?php topic_title(); ?></a></td>

    @gerikg

    Member

    Okay, but it still doesn’t solve my original problem.

    @illustrationism

    Member

    I want this same functionality.

    The problem is, these are all hacks. The bottom line is there’s no functionality to provide this.

    I’m disappointed… The more I look under the hood with BBPress, the more I’m kinda let down.

    @grassrootspa

    Member

    Having the same issue. Hopefully someone will solve this!

    @grassrootspa

    Member

    My apologies for bumping this up but:

    <td class="num"><a href="<?php $topic = $GLOBALS['topic'] = current( get_latest_topics( array( 'number' => 1, 'forum' => get_forum_id() ) ) ); ?>"><?php topic_title(); ?></a></td>

    …makes the last forum post appear, but the hyperlink does NOT work (the link generated is the current page that the reader is on).

    Any idea how to resolve this?

    @kevinjohngallagher

    Member

    If you look at your outputted HTML mate (ctrl+U if on firefox) can you tell us what that is?

    I’m guessing its:

    title

    off the top of my head there is a “topic-slug” that might be what you’re looking for, but i cant check my own code until i get home.

    @grassrootspa

    Member

    Hmmm, here is an example of what is being generated. Looks like the ahref is remaining blank ( <a href=""> ):

    <tr class="bb-precedes-sibling bb-follows-sibling bb-child alt">

    <td class="num" style=padding:2px><img src='http://newstalkpa.com/graphics/redfolder20.gif' width='30' height='20'><br></td>

    <td><div class="nest"><a href="http://newstalkpa.com/forum.php?id=23">Montgomery County</a><small> – Norristown, Conshohocken & Pottstown</small></div></td>

    <td class="num">1</td>
    <td class="num">3</td>
    <td class="num" style=padding:0px>
    <img src='http://www.gravatar.com/avatar.php?gravatar_id=9d50ea21b75d0928eaf9487d20e9da06' width='24' height='24'><br></td>
    <td class="num">
    <small><a href="http://newstalkpa.com/profile.php?id=118" >amstay</a></small>
    </td>

    <td class="num"><a href="">Castor replacement</td>

    <tr class="bb-precedes-sibling bb-follows-sibling bb-child">

    <td class="num" style=padding:2px><img src='http://newstalkpa.com/graphics/redfolder20.gif' width='30' height='20'><br></td>

    <td><div class="nest"><a href="http://newstalkpa.com/forum.php?id=26">Bucks County</a><small> – Doylestown, Levittown, Quakertown & Yardley</small></div></td>
    <td class="num">1</td>
    <td class="num">2</td>

    <td class="num" style=padding:0px>
    <img src='http://www.gravatar.com/avatar.php?gravatar_id=439035a0912b61919d4611d60a7904b2' width='24' height='24'><br></td>
    <td class="num">
    <small><a href="http://newstalkpa.com/profile.php?id=21" >frank</a></small>
    </td>

    <td class="num"><a href="">Pat Toomey In Bucks County - July 18th!</td>

    @gerikg

    Member

    This topic is resolved, I used Forum Last Poster plugin by _ck_ (https://bbpress.org/plugins/topic/forum-last-poster/)

    For last topic with link I used

    &lt;a href=&quot;&lt;?php forum_last_post_link();?&gt;&quot;&gt;&lt;?php topic_title(); ?&gt;&lt;/a&gt;

    Why can I paste code anymore?

    @kevinjohngallagher

    Member

    Hi Gerikg,

    _CK_’s last forum poster works awesomely (though I hit a few issues with it with 1.0, they were ultra minor).

    The downside for that plugin though is that it makes additional SQL calls that really shouldn’t be needed. That isn’t the fault of the plugin or _CK_ but really, it’s aditional overhead that really isn’t needed when there’s a better way of doing things.

    Also, Code’s been royally F@**ed for about a week now, given how much of a priority fixing the homepage was (404 error for 3-4 days) I rekon we can expect a fix in roughly 2.4 amotic years ;-)

    @kevinjohngallagher

    Member

    Found the post I was looking for mate – its a bit long and wordy:

    https://bbpress.org/forums/topic/somethings-holding-us-back-random-thoughts#post-64728

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