Aragon Online

Go Back   Aragon Online > Discussion > Programmer's Cubicle

Programmer's Cubicle A place where some code snippets and other nerdy things will be posted for the general programmer community's benefit.
Note that this is not a programming HELP forum. Posts not about the code here will be deleted or moved.

Thread Tools Display Modes
Old 02-21-2010, 07:12 PM
Merlin's Avatar
Merlin Merlin is offline
Supreme Wizard
City: Riverton
Race: Human
Wealth: 870,002
Population: 1,582
Join Date: Dec 2003
Location: The deepest dark of Oregon
Posts: 3,265
Merlin is on a distinguished road
Default vBulletin integration

I recently changed the way my HELP pages work to use a special forum, and threads from it, for most of the HELP page content. (There are some pages that pull data out of the database for display, so it is the pages that contain only text and images.)

I simply use the following code to grab the text from a thread, BBCode parse it, and display it. The function fetches only the first post in a thread, so other developers can use those threads for comments about the content without affecting the text that is displayed. It makes editing and revisions very simple - much easier than typing raw HTML into the PHP code.

Call it like this:
PHP Code:
    $help get_forum_help("New Game");

The function that does the hard work:
PHP Code:
/* *** FORUM FUNCTIONS ************************************************* */

$bbcode_parser = & new vB_BbCodeParser($vbulletinfetch_tag_list(), true);

get_forum_help($help_thread) {

$help_forum '1';  // Change to the forum that is used

    // Get the text, and last edit date, if any (that's the ORDER BY and LIMIT 1)
$sql =
"SELECT thread.threadid, thread.title, post.pagetext, " .
"COALESCE(editlog.dateline, thread.dateline) AS dateline " .
"FROM thread " .
"INNER JOIN post ON post.postid = thread.firstpostid " .
"LEFT JOIN editlog ON editlog.postid = post.postid " .
"WHERE thread.forumid = $help_forum " .
"AND thread.title = '$help_thread' " .
"ORDER BY editlog.dateline DESC " .
"LIMIT 1";

$help sql_query_first($sql);

// The title is not used
    // $help['title'] = unhtmlspecialchars( $help['title'] );
    // $help['title'] = xhtml_clean( $help['title'] );

    // Parse the BB Code and change new lines to break
$help['message'] = $bbcode_parser->do_parse($help['pagetext'], true,true,true,true,true);

// Make sure that the message has two new lines at the end
$help['message'] .= "<br /><br />";

$help['date'] = vbdate$vbulletin->options['dateformat'], $help['dateline'] );
$help['time'] = vbdate$vbulletin->options['timeformat'], $help['dateline'] );

$help['last_edit'] =
"<br /><br /><p align='right'><font size='-2'><i>" .
"Last Edit ".$help['date']." ".$help['time'] .


Do not meddle in the affairs of wizards, for they are subtle and quick to anger.
The Lord of the Rings
Gildor, Chapter 'Three is Company'.

Last edited by Merlin; 02-25-2010 at 12:41 AM.
Reply With Quote


Thread Tools
Display Modes

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

Forum Jump

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

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright ©2003 - 2012 by Unintended Features