Closed Thread
Results 1 to 1 of 1

Thread: [HowTo] Display your latest threads on an external page using an RSS feed

  1. #1
    vBulletin Team Colin F will become famous soon enough Colin F will become famous soon enough Colin F's Avatar
    Join Date
    May 2004
    Location
    Switzerland
    Posts
    17,634

    [HowTo] Display your latest threads on an external page using an RSS feed

    This HowTo explains what needs to be done to include the 10 latest threads from your forums on an external PHP page using the RSS feed.

    ---------------------------------
    1. Near the top of your php page, but after the <?php code include the following:
      Code:
      // ######################################################
      // ## configuration
      // ##
      // ## $rss_file= 'http://www.vbulletin.com/forum/external.php?type=rss';
      // ## Adjust this variable to point to your RSS feed
       
      $rss_file = 'http://www.vbulletin.com/forum/external.php?type=rss';
          
      // ## configuration end
      // ######################################################
      // ## Do not touch code below!
          
          
      $is_item = false;
      $tag = '';
      $title = '';
      $description = '';
      $link = '';
          
      function character_data($parser, $data)
      {
          global $is_item, $tag, $title, $description, $link;
          if ($is_item)
          {
              switch ($tag)
              {
                  case "TITLE":
                  $title .= $data;
                  break;
                  case "DESCRIPTION":
                  $description .= $data;
          
                  break;
                  case "LINK":
                  $link .= $data;
                  break;
              }
          }
      }
          
      function begin_element($parser, $name)
      {
          global $is_item, $tag;
          if ($is_item)
          {
              $tag = $name;
          }
          else if ($name == "ITEM")
          {
              $is_item = true;
          }
      }
          
      function end_element($parser, $name)
      {
          global $is_item, $title, $description, $link, $rss_output;
          if ($name == "ITEM")
          {
              $rss_output .= "<dt><strong><a href='" . trim($link) . "'>" . htmlspecialchars(trim($title)) . "</a></strong></dt><dd>" . htmlspecialchars(trim($description)) . "</dd>";
              $title = "";
              $description = "";
              $link = "";
              $is_item = false;
          }
      }
          
          
      $parser = xml_parser_create();
          
      xml_set_element_handler($parser, "begin_element", "end_element");
      xml_set_character_data_handler($parser, "character_data");
      $fp = fopen($rss_file,"r");
          
      while ($data = fread($fp, 4096))
      {
          xml_parse($parser, $data, feof($fp));        
      }
          
      fclose($fp);
      xml_parser_free($parser);
    2. Make sure to adjust the $rss_file variable at the very top of the code you just added.
    3. Add the following code to wherever on that page you want to display the output:
      Code:
      echo $rss_output;
    Attached Images
    Last edited by Floris; Wed 12th Oct '05 at 5:30pm.
    Best Regards
    Colin Frei

    Please don't contact me per PM.

Closed Thread

Similar Threads

  1. HowTo Display Latest Active Threads on Forumhome
    By Floris in forum vBulletin 3.5 Quick Tips and Customizations
    Replies: 2
    Last Post: Tue 30th May '06, 11:40am
  2. HowTo Display Latest Active Threads on ANY normal HTML page
    By Floris in forum vBulletin 3.5 Quick Tips and Customizations
    Replies: 2
    Last Post: Tue 30th May '06, 11:38am
  3. External RSS Post Feed
    By jdingman in forum vBulletin 3.5 'How Do I' Questions and Troubleshooting
    Replies: 4
    Last Post: Fri 14th Oct '05, 1:52am
  4. How to parse the RSS external.php feed
    By Olate in forum vBulletin 3.0 How Do I and Troubleshooting Forum
    Replies: 4
    Last Post: Thu 17th Jun '04, 2:13pm
  5. RSS External Feed - Poster
    By Olate in forum vBulletin 3.0 How Do I and Troubleshooting Forum
    Replies: 0
    Last Post: Tue 13th Apr '04, 8:49am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts