I apologize, I said I would post up the GARs tab that I completed and I completely forgot. For those of you using GARs for articles on your vBulletin forums, if you would like to display the latest recent GARs articles within an Ajax TAB you can do so with the following .php file:
Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'tabrecentthreadsexp'); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
);
// get special data templates from the datastore
$specialtemplates = array(
);
// pre-cache templates used by all actions
$globaltemplates = array(
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
//require_once('./includes/vba_cmps_include_template.php');
require_once('./includes/vba_cmps_global.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
?>
<?php
echo '<table border="0" cellpadding="0" cellspacing="0" width=100%><tr>';
$modulehtml = "";
$x = 0;
$bburl = $vbulletin->options['bburl'];
$forumids = ""; // Comma seperated list of forumids
$limit = 4; // How many items to show
$title = ""; // Module Title
$featured = 0; // 1= Only featured items
$url_to_default_image = "types/3/default.jpg"; //Relative URL to default image from geek/gars/images/ folder
$vertical = 0; // 1= Vertical (only for template 1 or 3)
$preview = 1; // 1= Show preview
$ratings = 0; // 1=show ratings
$template = 2; // 1=simple with pic, 2=big with pic, 3=Listing no pic
$order = 1; // 0 = rand, 1=desc, 2=asc
$maxchars = 150; // Maximum amount of chards to snip
$customfields = false; // Set to true to grab the custom fields.
$parsebb = true; //set to true to parse preview
switch ($order)
{
case 0:
$order = "RAND()"; break;
case 1:
$order = "g.threadid DESC"; break;
default:
$order = "g.threadid ASC";
}
if (!$limit)
{
$limit = "1";
}
// COMMENTED OUT FOR TESTING
($hook = vBulletinHook::fetch_hook('vba_cmps_module_recthreads_start')) ? eval($hook) : false;
// Main SQL
$results = $db->query_read("SELECT g.threadid,g.header_image image, p.title, g.byline" .
($preview ? ", IF(g.synopsis, g.synopsis, p.pagetext) synopsis " : "") .
($ratings ? ",round((g.overall_rating/10),0) author_rating, g.overall_rating author_rating_percent,round((g.avg_rating/10),0) member_rating, g.avg_rating member_rating_percent " : "" ) .
",g.pagecount, g.custom2 $customfields FROM
" . TABLE_PREFIX . "gars g
" . ($customfields ? " INNER JOIN " . TABLE_PREFIX . "gars_custom_values gsv ON gcv.custom_threadid = g.threadid " : "") . "
INNER JOIN " . TABLE_PREFIX . "thread t ON g.threadid = t.threadid
INNER JOIN " . TABLE_PREFIX . "post p ON t.firstpostid = p.postid
WHERE t.visible = 1 AND t.open != 10
" . ($forumids ? " AND t.forumid in ($forumids) " : "" ) . "
" . ($featured ? " AND g.feature_untill> " . TIMENOW : "") . "
ORDER BY $order LIMIT $limit");
while ($result = $db->fetch_array($results))
{
if (!$result['image'])
{
$result['image'] = $vbulletin->options['bburl'] . "/geek/gars/images/" . $url_to_default_image;
}
elseif (substr($result['image'], 0, 1) == ".")
{
$result['image'] = $vbulletin->options['bburl'] . substr($result['image'], 1);
}
else
{
$result['image'] = $vbulletin->options['bburl'] . $result['image'];
}
if ($parsebb && $template!=3)
{
$result['message'] = strip_bbcode($result['synopsis']);
}
if (strlen($result['message']) > $maxchars)
{
$result['message'] = substr($result['message'], 0, strrpos(substr($result['message'], 0, $maxchars), ' ')) . '...' . ($template!=3 ? construct_phrase($vbphrase['read_more'], $vbulletin->options['bburl'], $result['threadid'], $session['sessionurl']) : "");
}
if (strlen($result['message']) > $maxchars)
{
$result['message'] = substr($result['message'], 0, strrpos(substr($result['message'], 0, $maxchars), ' ')) . '...' . ($template!=3 ? construct_phrase($vbphrase['read_more'], $vbulletin->options['bburl'], $result['threadid'], $session['sessionurl']) : "");
}
eval('$bits = "' . fetch_template('adv_portal_gars_bit' . $template) . '";');
echo '<tr>' . $bits . '</tr>';
}
echo "</table>";
?>
Basically, I just took the GARs vB CMPS module file and merged it with the recent threads tab file that came with this Ajax TABS script (I think thats what I did? It's been a little while so I kind of forgot.
)
I hope this helps anyone using GARs and the Ajax TABs script. You can see this running live at my website (
www.ready-up.com). There is currently a small bug in firefox with my nested tabs, just hit the "Home" link on the top of the page if you are using firefox and you should be able to see the tabs working perfectly after that. PM me if you have any questions or problems setting that up.
Thanks again bob, wonderful script!