Thread: Add-On Releases - AJAX Tabs Content Script v2
View Single Post
  #113  
Old 02-07-2008, 11:10 PM
ZiG ZiG is offline
 
Join Date: Oct 2002
Posts: 176
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01590 seconds
  • Memory Usage 1,789KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete