网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > vBulletin技术交流
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

vBulletin技术交流 主要讨论vBulletin的安装使用、模板风格、插件以及小技巧等。

Reply
 
Thread Tools Display Modes
  #1   IP: 153.99.23.103
Old 2015-04-05, 03:11 PM
Maine Maine is offline
初级会员
 
Join Date: 2006-11-02
Posts: 1
Maine 现在声名狼藉
Default Vbulletin Display your latest threads on an external page using an RSS2 feed

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

1. Near the top of your php page, but after the <?php code include the following:
Code:
// ######################################################
// ## configuration
 // ##
 // ## $rss2_file= 'http://www.vbulletin.com/forum/external.php?type=rss2';
 // ## Adjust this variable to point to your RSS2 feed
  
 $rss2_file = 'http://www.vbulletin.com/forum/external.php?type=rss2';
     
 // ## configuration end
 // ######################################################
 // ## Do not touch code below!
     
     
 $is_item = false;
 $tag = '';
 $title = '';
 $description = '';
 $link = '';
 $date = '';
 $author = '';
     
 function character_data($parser, $data)
 {
     global $is_item, $tag, $title, $description, $link, $date, $author;
     if ($is_item)
     {
         switch ($tag)
         {
             case "TITLE":
             $title .= $data;
             break;
     
             case "DESCRIPTION":
             $description .= $data;
             break;
     
             case "LINK":
             $link .= $data;
             break;
     
             case "PUBDATE":
             $date .= $data;
             break;
     
             case "AUTHOR":
             $author .= $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, $date, $author, $rss2_output;
     if ($name == "ITEM")
     {
         $rss2_output .= "<dt><strong><a href='" . trim($link) . "'>" . htmlspecialchars(trim($title)) . "</a></strong> - " . htmlspecialchars(trim($date)) . " by <em>" . htmlspecialchars(trim($author)) . "</em></dt><dd>" . htmlspecialchars(trim($description)) . "</dd>";
         $title = "";
         $description = "";
         $link = "";
         $date = "";
         $author = "";
         $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($rss2_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 $xml_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 $rss2_output;
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Speed up your vBulletin forums! topvip vBulletin技术交流 0 2013-03-01 08:17 PM
Show latest threads on showthread topvip vBulletin技术交流 0 2009-07-29 07:04 AM
HowTo Display Latest Active Threads on ANY normal HTML page topvip vBulletin技术交流 1 2009-07-29 07:03 AM
What are the Strongest Directories? smiling 网站链接开发 1 2007-07-28 09:26 PM
Building for the user and the bot. admin 建站交流 0 2006-01-17 03:54 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:56 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.