Welcome to Olinewebmarket

Thread: Include some entries from vBulletin on non vb pages?
masterweb's Avatar
  post #1   masterweb is offline
Old 01-04-2009, 03:15 PM
masterweb
Site Owner
More info Spam Post Send a message via Yahoo to masterweb
Join Date: Aug 2007
Location:
 Italy
Posts:
 4,861
masterweb is an unknown quantity at this point
Default Include some entries from vBulletin on non vb pages?
As Admin of a vBulletin based board i’m used to edit the pages (or templates) generated into the board itselfs but if i need to edit a non vBulletin page including any info from a vBulletin one then things become a bit complicated. That’s due vBulletin uses some internal “vars” that not always can be executed directly out the forum. Today looking to add on our home page the “New Listings at OnlineWebMarket” field with latest posts made just on the market section I learned the following:

You can add on your non vBulletin page (if a php one of course) a piece of script by any RSS online tool similar to the one created using http://rssjava.com, but there is problem: from time to time you will face errors alike

Quote:
Error: Feed failed! Causes may be (1) No data found for RSS feed http://www.onlinewebmarket.net/exter...=0&fulldesc=0; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

Please verify that the URL http://www.onlinewebmarket.net/exter...l=0&fulldesc=0 works first in your browser and that the feed passes a validator test.
It means that the script can’t read at all the original source of the RSS (in this case our “Market” section). So how to include your latest posts made on a particular forum on your non vBulletin page?. Well here you have how:

Following the URL http://www.vbulletin.com/forum/showthread.php?t=159044 we can see a valid code to insert this info via RSS on the home page of our board (OWM represents our “Study Case”), but adding this code as is we will see the full RSS entries made on the forum on Home Page, how to show just the entries from a particular category?, just take a look at the edited code:

Quote:
<?php
// ################################################## ####
// ## 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.onlinewebmarket.net/external.php?type=RSS2&forumids=170,56,52,74,159,1 67,20,22,23,58,168,24,41,54,25,44,55,169,26,75,171 &lastpost=1&nohtml=0&fulldesc=0';

// ## 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 "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, $date, $author, $rss2_output;
if ($name == "ITEM")
{
$rss2_output .= "<dt><a href='" . trim($link) . "'>" . htmlspecialchars(trim($title)) . "</a>". "</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);
?>
Instead of using the main URL of the site to retrieve RSS entries from the entire forum (all posts made around the whole forum we can use the following URL:

What it means?, well the numbers after “forumids” tells the script to retrieve entries made “ONLY” on the forums (or subforums) number 170, 56, 52, 74 and so on. In resume this little modification made to the original code provided by vbulletin.com helps us to show the posts made only on selected forums, an easy way to include on our external non vBulletin page info from the board itself.

Of course in order to use this URL as the source from where the RSS should read the "News" you must install a mod alike the one we are using "Sorky12 - RSS Feed Links - V1.0.0" available for free at: http://www.vbulletin.org/forum/showthread.php?t=194082 (in order to download it you must be registered with your Jelsoft's client ID)

I’m not a hack developer (I’m to lazy), I’m just posting my personal test for any one looking a guide on how to include info from vBulletin boards outside the board. Hope you make profit from it :).


Last edited by masterweb; 01-04-2009 at 03:49 PM.

Closed Thread
Forum Jump Top
 
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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
 
 
All times are GMT. The time now is 02:26 PM.
original style @ vBulletin.com (version 4)