Search code examples
phpmybb

Getting myBB threads from a specific forum and display them on another page?


Hello I am trying to display up to 5 threads on my homepage from a specific forum. So I want to get the threads from 'Announcments' located in http://example.com/forum and display them on the homepage in a list.

How can I do this using PHP?


Solution

  • Follow these steps to get an RSS feed from MyBB: http://wiki.mybb.com/index.php/RSS_Syndication. Looks like you can set the limit to 5 threads and select a forum to syndicate.

    Then it's a matter of parsing your RSS feed using PHP. Half-baked code to get you started:

    $xml = simplexml_load_string($feed);
    
    $items = $xml->channel->item;
    
    foreach($items as $item) {
      $title = $item->title;
      $link = $item->link;
      $pubDate = $item->pubDate;
      $description = $item->description;
    
      // echo and format variables
    
      }