Skip to:
Content
Pages
Categories
Search
Top
Bottom

Full Content of Most Recent Post on Front-Page?


  • yottabite
    Member

    @yottabite

    Is there any way to make a function, say: “get_latest_topic”, or simply limit the “get_latest_topics” function to display only the latest topic, but also include the full post?

    If not, there may be some other way that I am missing in order to add the content of the latest post to the frontpage, without going all-out and using Worpress for this view.

    Thanks in advance!

Viewing 25 replies - 1 through 25 (of 45 total)

  • yottabite
    Member

    @yottabite

    OK I’ve figured it out.

    I used RSS2HTML, and got the results I needed.

    For an example, checkout:

    http://forum.blandname.com

    Basically, you just include the RSS2HTML.php file in front-page.php, set the template location in the RSS2HTML.php file, and pick how many entries you’d like to have displayed.

    To play with the look and feel, you can use the sample-template.html file, and tweak ’til your heart’s content.

    This is a really nice idea. I’ll work on getting some convenience functions written for the next “major” release.

    I love this, can you explain more detailed (for us noobs) what you did and what you added, changed? Step by step? Can’t get this to work with the small details you gave!

    Thx

    Got it to work, but I see all 35 feeds, where to change that I also only see the last posted topic (and NOT the replies)

    Sec, is it possible to only show the last 10 topics (and not the replis on them) from a certain forum? So I only see the last 10 topics from forum with id 1

    Thx


    so1o
    Participant

    @so1o

    you can use this

    $topics = get_latest_topics( $forum_id);

    but this will give you number of topics/page that you set in your config

    to get just 10 topics from the forum

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

    Oke and in what file do I put this? And also where do I put the 1? (1 = forum id)

    Sorry I am noob :)


    so1o
    Participant

    @so1o

    you can put this where you want to display the 10 topics from the forum.. if you want to display it on frontpage then you put it in template for frontpage…

    note that the variable names will need to be changed as there are lot of global variables by the same names.. give some unique variable names

    <?php $topics = $bbdb->get_results(“SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC LIMIT 0,10”) ?> gives me a error:

    bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY topic_time DESC LIMIT 0,10’ at line 1]

    SELECT * FROM bb_topics WHERE forum_id = ORDER BY topic_time DESC LIMIT 0,10


    so1o
    Participant

    @so1o

    As you can see in the sql.. you have not defined your $forum_id.. before you call the sql define $forum_id which is the id of the forum for which you want to display the topics..

    let me know

    Ow I forgot the forum_id…

    K I now have this in frontpage.php:

    <?php

    $forum_id = 1;

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

    This takes away the error but doesn’t display anything either..

    Greetz The Noob :)


    so1o
    Participant

    @so1o

    sorry Null .. but this is the core code.. that will give you the topics..

    you will have to write a loop to display the topics eg:

    $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) :

    ?>

    <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>

    <?php

    endforeach;

    again: i warn watch where you put it. there are a lot of global variables. dont put in place where you are displaying other topics and stuff

    Made some changes, but this works:

    <?php

    $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") ?>

    <?php foreach($forum_one_topics as $topic) :

    ?>

    <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a><br />

    <?php endforeach; ?>

    but it doesnt show the typed text only the title of the forum. What to add to also show the typed text (NOT the replies ofcourse)

    Many thx


    so1o
    Participant

    @so1o

    <?php

    foreach($forum_one_topics as $topic) :

    $forum_one_topic_posts = get_thread( $topic->topic_id);

    ?>

    <?php topic_title(); ?><br/>

    <?php

    echo $forum_one_topic_posts[0]->post_text;

    endforeach;

    ?>

    Perfect thank you so much

    One more question, this way I can also add things like topic_poster right?

    Can you give me one more excample of how to add the topic poster to this code as well? I think I get the hang of this and can figure things like topic_time etc out myself if I get that last part I asked!

    Greetz

    you can do

    echo get_user($topic->topic_last_poster);

    EDIT:

    Oops, better way

    echo $topic->topic_last_poster_name;

    Thank you for your help!

    no problem

    Hi,

    I am stuck again. I wanted to split the code to the php part and the template part. I did this:

    In index.php I’ve added (right after require('./bb-load.php') ;:

    $forum_id = 1;

    $number_of_topics = 10;

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

    In front-page.php I’ve added:

    <?php

    foreach($forum_one_topics as $topic) :

    $forum_one_topic_posts = get_thread( $topic->topic_id); ?>

    <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>

    <?php echo $topic->topic_last_poster_name; ?><br/>

    <?php echo $forum_one_topic_posts[0]->post_text;

    endforeach;

    ?>

    But this results in errors on the index.php file:

    parse error, unexpected T_STRING on the first line after the code I’ve put in the index.php file.

    What am I doing wrong?

    Fixed it. For some reason putting

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

    in index.php gives the error, but placing it into front-page.php fixes it, no errors and it works…

    Hi,

    Can some kind soul walk me through how to acheive this?

    Cheers!

    awesome, how would i get the poster’s name to become a link to their profile?

    I don’t know off the top of my head. What I’d do in this case, as for pretty much every question that’s asked, is open my copy of bbPress and look around in the files. So that sort of thing sounds like a template tag, so I’d look at bb-includes/template-functions.php, then search for “profile_link” or a couple other similar terms if I couldn’t find it.

    This time I tested it and searching for “profile_link” will pretty quickly get you the function you want. But finding out what you need is something you can pretty easily do yourself most of the time. :)

    (Not that there’s a problem with you asking anything, this is just teach-a-man-to-fish thinkin’.)

    i hear what you’re saying but believe me, i tried my damndest to figure it out myself before i posted (as i do before all my questions). the problem is i don’t really understand the syntax of php code just yet so i don’t know how to use the get_user_profile_link(); function in this particular example (getting the profile link of the last poster from the entire messageboard onto the front page, it’s a little confusing). if you can give me some help on this one, i’d appreciate it.

    i have another question about the most recent post on the front page. i got it working great from what was written in this post. however, i then deleted a forum (from position 0) and once i did that, an error appeared where the text from the most recent post used to be:

    Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/bb-templates/superbold/front-page.php on line 13

    any thoughts on how i can correct this and make it work again?

    $topic->topic_last_poster is the ID of the last poster to the topic. user_profile_link( $user_id ) echoes the url of the user’s profile. You’d do something like this I think:

    <a href="<?php user_profile_link( $topic->topic_last_poster ); ?>"><?php echo $topic->topic_last_poster_name; ?></a>

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