vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   [ Release v2.0.1 ] External discussion links (join/start a conversation!) (https://vborg.vbsupport.ru/showthread.php?t=20706)

06-18-2001 10:00 PM

Another quick, but kick-arse hack. We have a home-made content management system (actually, a beta tool see incursio.com for more info - product is called Editio). At any rate, it allows staff or community members to create online articles. Once articles are published, I wanted a way to automatically link them into our forums, so people could start a discussion, or join a discussion already in progress about that particular article. Yahoo! does this with news events as well.

At any rate, perl script. chmod 755, I call it discuss_link.cgi. It should be invoked via SSI. Under Apache:

Code:

  <!--#include virtual=/cgi-bin/discuss_link.cgi?topic=Downhill+Skiing+Basics&forum=5 -->
In the link above, plug in your forum number (forumid column in VB), and the title of the article. The title will be used as the title of the post. If a post exists in the passed forum with that title, a link to "Join the conversation" will be emitted. Otherwise, you get a link called "Start a conversation". You get the picture.

Our content management system (through its plugin concept) allows us to have stuff like this embedded within each article - you could cobble up something similar in your own system with a little effort.

Code:

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

use DBI;

#Require the cgi library
require '/opt/web/cgi-bin/cgi-lib.pl';

&ReadParse(*input);

# Grab fields
$topic =  $input{'topic'};
$forum =  $input{'forum'};

# Does the forum/topic combo exist?

# Connect to mySQL

$dbh = DBI->connect( "DBI:mysql:vbulletin", "id", "password");

if ( !defined $dbh ) {
  print "<LI>Cannot connect to mySQL server: $DBI::errstr\n";
}

# Grab the forum name

$q = "SELECT title FROM forum WHERE forum = $forum";

$sth = $dbh->prepare($q);
$sth->execute;
@result = $sth->fetchrow_array;
$forum_name = $result[0];
$sth->finish;

$quoted_title = $dbh->quote($topic);
$q = "SELECT threadid FROM thread WHERE forumid = $forum AND title = $quoted_title";
$sth = $dbh->prepare($q);
$sth->execute;
@result = $sth->fetchrow_array;
$threadid = $result[0];
$sth->finish;

# Prep for linking
$topic =~ tr/ /+/;

if( $threadid <= 0 ) {
  print "<A HREF=http://www.mysite.com/forums/newthread.php?s=&action=newthread&forumid=$forum&subject=$topic>Start a Conversation!</A>";
  exit(1);
}

print ("<A HREF=http://www.mysite.com/forums/showthread.php?s=&threadid=$threadid>Join the Conversation!</A>");

exit;

Cheers.

unixman 06-19-2001 05:58 PM

For those who'd like to see it in action - take a peek:

http://www.wetcanvas.com/Articles/Scott_Burkett/105/

Check the bottom of the page.

Cheers.

Nicholas Brown 06-20-2001 06:50 AM

Good hack, but you should have done it in PHP and not icky pUrl :)

Balbanes 06-20-2001 11:07 AM

Oh wow that really is cool!

I think it would be good for long community news articles too.

unixman 06-20-2001 11:44 AM

So rewrite in PHP. I wrote it in Perl because it was done long before I ever had vbulletin.

v0n 06-20-2001 11:50 AM

unixman - you are the man! Thanks for the hack.

TigerLily 06-20-2001 03:26 PM

Awesome hack! Thank you very much!

Any idea on when Editio will be ready for release? Looks like a cool product.

TigerLily:)

unixman 06-20-2001 04:18 PM

A bit off-topic for this board, but over the summer for sure. Just add yourself to our mailing list and you'll be the first to know. :-)

Cheers.

akiy 06-20-2001 05:33 PM

Quote:

Originally posted by unixman
So rewrite in PHP.
I went and rewrote the above in PHP. I've attached discussion_link.php below.

All you should need to do is include("discussion_link.php") where you would like the "Start/Join a Conversation!" link to be. You'll need to set your own username, password, database, and forumpath in the script, of course.

I've tried out the script on my site and it looks like it works. Any improvements, bug fixes, and such are always welcome.

ztsky 06-21-2001 11:08 PM

Cool!
But how to use it?


All times are GMT. The time now is 01:37 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02380 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete