Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
Displaying the latest posts from a thread in an external page for reviews/news Details »
Displaying the latest posts from a thread in an external page for reviews/news
Mod Version: 1.00, by Spinball (Member) Spinball is offline
Developer Last Online: Sep 2019 I like it Show Printable Version Email this Page

vB Version: 3.8.2 Rating: (0 vote - 0 average) Installs: 4
Released: 14 Apr 2009 Last Update: Never Downloads: 1
Not Supported Template Edits Re-usable Code Translations  

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.

Download Now

Only licensed members can download files, Click Here for more information.

Screenshots

Click image for larger version

Name:	Image1.jpg
Views:	864
Size:	139.5 KB
ID:	97767  

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • If you like this modification support the author by donating.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Comments
  #2  
Old 14 Apr 2009, 19:10
Jasem's Avatar
Jasem Jasem is offline
 
Join Date: Feb 2006
Location: www.menokia.com
Nice work, thank you!
__________________
games
Forum Nokia
Reply With Quote
  #3  
Old 28 May 2009, 22:12
CMFINC CMFINC is offline
 
Join Date: Feb 2007
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
Reply With Quote
  #4  
Old 28 May 2009, 22:26
nnStaff nnStaff is offline
 
Join Date: May 2009
pretty nifty
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

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


New To Site? Need Help?

All times are GMT. The time now is 06:51.

Layout Options | Width: Wide Color: