MyBB Community Forums

Full Version: Add Latest Posts to Index Page Sidebox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As the title states, how can I add the latest posts to my index page side box? I already have the sidebox built...just need the variable or code to add the latest posts.
BUMP because I am looking for this also! Big Grin
Small bump on this. I want to add the last 5 posts in the sidebox, can anybody advise what code or modification to the plugin i need to do.

Thanks
J
A quick way of doing is to use PHP simpleXML and MyBB's RSS Feed. You'll need to grab your forums XML feed (The link should be on the footer called 'RSS Syndication'). Here's the code to grab and parse the feed:


<?php


            $xml = simplexml_load_file('http://yourforum.com/forum/syndication.php?limit=5');

            foreach($xml->channel->item as $items) {
            // title of the post thread
            $title = $items->title;
             // URL for the post
            $link = $items->link;
            // grabs description for each post (includes html) 
            // good for showing info of the post before clicking
            $descRaw = $items->description;
            // strips html from post
            $desc = strip_tags(truncate($descraw, 145));
            // echo out whatcha want            
            echo '<li><a href="'.$link.'" title="'.$desc.'">'.$title.'</a></li>';
          }
          ?>

What am I missing? I changed the syndication to my forum and inserted the code into my index page sidebox area, but I get this as output in my sidebox...

item as ) { // title of the post thread = ; // URL for the post = ; // grabs description for each post (includes html) // good for showing info of the post before clicking = ; // strips html from post = strip_tags(truncate(, 145)); // echo out whatcha want echo '
'..'
'; } ?>