Helpful Information
 
 
Category: vBulletin 3.8 Template Modifications
Integration with vBulletin - Displaying the latest posts from a thread in an external page for reviews/news

We publish movie and hardware reviews using their own databases and CMS style scripts I created. I wanted to incorporate discussions related to those reviews along side them. I have wanted to do this for ages, but only just cracked it and I thought I would share my findings here.

Hopefully a moderator will move this thread if it is in the wrong forum.

Ok firstly I am displaying a discussion thread in web pages external to my forums but on the same server. That's the first restriction.
Also since I have vBSEO installed, the page *has* to be in a different folder than my forums otherwise vBSEO redirects calls to my page to the forums instead.
Ok, so my reviews are in AVForums.com/reviews and my forums are in AVForums.com/forums.

I need to link a discussion thread to each review and a threadid field in the review table allows that.
I could manually create a thread for each review and then update the threadid in the review, but it can be done automatically.
I have created an RSS feed for our reviews and I'm using the vBulletin RSS to thread functionality to automatically create a new thread within an hour of a new review being published. Since I know what the title of the automatically created thread will be, and what forum it will be in, I can interrogate the thread table to find the threadid and write it into the review. I wrote a script to do this and a cron job to fire it every hour. Easy.

So now we have our review and our discussion thread and the threadid is stored in the review record.
Now all we have to do is display the last page of the discussion thread in our review. Since our reviews are split into tabs, I created a new 'Comments' tab for this purpose.

Next I created a new template called SHOWTHREAD_embedded and copied the contents of the SHOWTHREAD template into it. I then removed all the elements of the page I don't want like the <body> tags and everything outside of them along with some of the buttons and the moderation and menu elements. I don't need this stuff since it's a basic comments page with limited functionality. Don't want to over complicate things.

Then I made a copy of showthread.php called showcomments.php, changed the 2 references to the SHOWTHREAD template to SHOWTHREAD_embedded and saved into my reviews folder. This script can be tested directly by running /reviews/showcomments.php?t=123456 with any thread id replacing 123456. It returns the thread as you'd expect with no style applied (since we removed it from the template).

The last step is running the showcomments script when someone clicks the Comments tab on my review pages.
I use curl to do this:
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://www.avforums.com/reviews/showcomments.php?t=" . $review['threadid'] . "&page=9999");
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$comments = curl_exec($curl_handle);
curl_close($curl_handle);

And display $comments in your page.
Note that the page=9999 ensures you display the last page of your thread.

We do have an issue with the relative links used in the SHOWTHREAD_embedded template bring broken since we are in the reviews folder rather than the forums folder.
But since we have the comments in a string variable $comments, we can do some string replaces to fix these:
$comments = str_replace("<img src=\"customavatars/" , "<img src=\"../forums/customavatars/" , $comments);
$comments = str_replace("href=\"newreply.php" , "href=\"../forums/newreply.php" , $comments);
$comments = str_replace("href=\"showpost.php" , "href=\"../forums/showpost.php" , $comments);
$comments = str_replace("href=\"member.php" , "href=\"../forums/member.php" , $comments);
$comments = str_replace("href=\"showthread.php" , "href=\"../forums/showthread.php" , $comments);


And it works well.
I know it's very possibly inefficient and there are likely some things that could be done better, but even with my extremely limited knowledge of how vB works, I had it working in a couple of hours.
Any suggestions on how to improve it are welcome.
I hope this info helps someone.

Nice work, thank you!

you think this could be mod-ed to make a Automatic Discussion Thread? our site deals with program files in diff forums.. and really would like to have auto discussion thread posted when a file is posted.
thank you for any help or ideals

pretty nifty










privacy (GDPR)