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

hey, im not excellent at hard coding PHP so could I get a little bit of assistance in preparing a tabexternal.php for a specific GARs module I am trying to put together to work with this script. basically what this module does is pull the latest defined amount of stories you want pulled from a specific GARs forum, and displays it similarly to how recent threads are displayed in the recent thread tabexternal.php. the only difference is that there is a GARs header_image that is pulled, and also a byline that are taken from different sql tables (gars g sql tables, not thread tables). if any of you use GARs, you should have an idea of what i'm talking about.

here is the GARs module code i am trying to plug into your ajax tabs script:

Code:
<?php

        //SETTINGS

    $forumids = "20";   		//      Comma seperated list of forumids
    $limit = 5;         		//      How many items to show
    $title = "News"; 			//        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 = 1;      		//      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 = 400;    		//  Maximum amount of chards to snip
    $customfields = false; 		// Set to true to grab the custom fields.
    $parsebb = true;			//set to true to parse preview

    // END SETTINGS

    switch ($order)
    {
        case 0:
                $order = "RAND()"; break;
        case 1:
                $order = "g.threadid DESC"; break;
        default:
                $order = "g.threadid ASC";
    }
    if (!$limit)
    {
        $limit = "1";
    }


        $sql = "SELECT g.threadid,g.header_image image, p.title, g.byline, t.forumid, t.dateline, t.postuserid, t.postusername " .
                ($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 ? ",gcv.*" : "") . " FROM
            " . TABLE_PREFIX . "gars g
            " . ($customfields ? " INNER JOIN " . TABLE_PREFIX . "gars_custom_values gcv 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";

        $results = $db->query_read($sql);
    $modulehtml = "";
    $x = 0;
    $bburl = $vbulletin->options['bburl'];
    if ($template==2)
    {
        $vertical = 1;
    }

    $mods['colspan'] = ($template==2 ? 3 : $x);
    $mods['collapse'] = $mods['modid'];
    $modcollapse = $vbcollapse["collapseobj_module_" . $mods['modid'] . ""];
    $modimgcollapse = $vbcollapse["collapseimg_module_" . $mods['modid'] . ""];

    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'] = $bbcode_parser->do_parse($result['synopsis'], 0, 1, 1, 1);
        }
        else
        {
            $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']) : "");
        }

        $result['dateposted'] = vbdate($vbulletin->options['dateformat'], $result['dateline']);

        eval('$bits = "' . fetch_template('adv_portal_gars_bit' . $template) . '";');

        if ($vertical && ($template != 2))
        {
            $modulehtml .= "<tr>$bits</tr>";
        }
        elseif ($vertical && $template == 2)
        {
                $mods['title'] = "<a href=\"$bburl/showthread.php?t=$result[threadid]\">$result[title]</a>";
                $modulehtml = $bits;
                eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_module_shell') . '";');
        }
        else
        {
            $modulehtml .= $bits;
            $x++;
        }


    }
    if ($modulehtml && ($template != 2))
    {
        if (!$vertical)
        {
                $modulehtml = "<tr>$modulehtml</tr>";
        }
        $home[$mods['modid']]['content'] .= $modulehtml;
    }
    elseif ($modulehtml && $template == 2)
    {
        $mods['noshell'] = true;
    }


?>
This is actually a CMPS module file, intended to be used with vBa CMPS, plugged in via the CMPS module system. you can find the actual module file and more information on the module here:

http://www.thevbgeek.com/showthread.php?t=1439

You can see the module running right on my webpage, underneath the News & Press Releases block, over at:

http://www.ready-up.com

Please help me to get this module running within the ajax tabs, I think it would be a great addition to this script as a lot of people use GARs. I tried myself to get it working, and I will continue trying on my own but like I've said i'm not so great at hardcoding PHP so i'm posting here in hope of getting a little bit of assistance. if i do happen to get this working, i will post the tabexternal php files for everyone else to use.

thanks in advance to anyone who helps out
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02011 seconds
  • Memory Usage 1,791KB
  • 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