Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 11-29-2008, 08:56 AM
zglows zglows is offline
 
Join Date: Oct 2007
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Please help me call this template!

I'd like to display $similarthreads in POSTBIT.
I've been working on this for days but I can't seem to make it happen.

If you help me, I'll pay you through Paypal. Please PM me.
Reply With Quote
  #2  
Old 11-29-2008, 10:00 AM
ReCom ReCom is offline
 
Join Date: Mar 2008
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

err .. why do you need to show $similarthreads in POSTBIT? if on one page there are 10 postbits, all of them will be showing the same list of threads over and over, you want that?
Reply With Quote
  #3  
Old 11-29-2008, 11:15 AM
zglows zglows is offline
 
Join Date: Oct 2007
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I want $similarthreads in postbit so I can display similar threads after the first post.
Then I'll make them display just once.
Reply With Quote
  #4  
Old 11-29-2008, 11:45 AM
ReCom ReCom is offline
 
Join Date: Mar 2008
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looking at showthread.php for vb 3.7.4, seems like there's no hook for putting stuff after first posts of showthread pages. Plus the codes that generate the simir threads listing are located way after (in term of execution flow) the codes that generate the postbits. The only choice is to totally modify your showthread.php by moving the codes that generate similar threads listing to before codes that generate the postbits. Easier said than done: you will have to be proficient in PHP and vBulletin architecture to understand the execution flow to make sure you don't mess up the file.
Reply With Quote
  #5  
Old 11-29-2008, 11:57 AM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what about using global_start?
Reply With Quote
  #6  
Old 11-29-2008, 01:37 PM
zglows zglows is offline
 
Join Date: Oct 2007
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your replies guys

I've made a plugin out of this code from showthread.php

PHP Code:
// *********************************************************************************
// get similar threads
if ($vbulletin->options['showsimilarthreads'] AND $thread['similar'])
{
    
// don't show similar threads from coventry
    
if ($coventry fetch_coventry('string'))
    {
        
$globalignore "AND thread.postuserid NOT IN ($coventry)";
    }
    else
    {
        
$globalignore '';
    }

    
$hook_query_fields $hook_query_joins $hook_query_where '';
    (
$hook vBulletinHook::fetch_hook('showthread_similarthread_query')) ? eval($hook) : false;

    if (
$vbulletin->userinfo['userid'] AND in_coventry($vbulletin->userinfo['userid'], true))
    {
        
$tachyselect "
            IF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost,
            IF(tachythreadcounter.userid IS NULL, thread.replycount, thread.replycount + tachythreadcounter.replycount) AS replycount
        "
;
        
$tachyjoin "
            LEFT JOIN " 
TABLE_PREFIX "tachythreadpost AS tachythreadpost ON
                (tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " 
$vbulletin->userinfo['userid'] . ")
            LEFT JOIN " 
TABLE_PREFIX "tachythreadcounter AS tachythreadcounter ON
                (tachythreadcounter.threadid = thread.threadid AND tachythreadcounter.userid = " 
$vbulletin->userinfo['userid'] . ")
        "
;
    }
    else
    {
        
$tachyselect "thread.lastpost, thread.replycount";
        
$tachyjoin "";
    }

    
$simthrds $db->query_read_slave("
        SELECT thread.threadid, thread.forumid, thread.title, thread.prefixid, thread.taglist, postusername, postuserid,
            
$tachyselect,
            forum.title AS forumtitle
            " 
iif($vbulletin->options['threadpreview'], ",post.pagetext AS preview") . "
            " 
iif($vbulletin->options['threadsubscribed'] AND $vbulletin->userinfo['userid'], ", NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed") . "
            
$hook_query_fields
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "forum AS forum ON (forum.forumid = thread.forumid)
        " 
iif($vbulletin->options['threadpreview'], "LEFT JOIN " TABLE_PREFIX "post AS post ON (post.postid = thread.firstpostid)") . "
        " 
iif($vbulletin->options['threadsubscribed'] AND $vbulletin->userinfo['userid'], " LEFT JOIN " TABLE_PREFIX "subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = " $vbulletin->userinfo['userid'] . " AND canview = 1)") . "
        
$hook_query_joins
        
$tachyjoin
        WHERE thread.threadid IN (
$thread[similar]) AND thread.visible = 1
            " 
iif (($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) OR ($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']) OR can_moderate($forumid), ''"AND forum.password = ''") . "
            
$globalignore
            
$hook_query_where
        ORDER BY lastpost DESC
    "
);

    
$similarthreadbits '';
    
$forum_active_cache = array();
    while (
$simthread $db->fetch_array($simthrds))
    {
        if (!isset(
$forum_active_cache["$simthread[forumid]"]))
        {
            
$current_forum $vbulletin->forumcache["$simthread[forumid]"];
            while (!empty(
$current_forum))
            {
                if (!(
$current_forum['options'] & $vbulletin->bf_misc_forumoptions['active']))
                {
                    
// all children of this forum should be hidden now
                    
$forum_children explode(','trim($current_forum['childlist']));
                    foreach (
$forum_children AS $forumid)
                    {
                        if (
$forumid == '-1')
                        {
                            continue;
                        }
                        
$forum_active_cache["$forumid"] = false;
                    }
                    break;
                }

                
$forum_active_cache["$current_forum[forumid]"] = true;
                
$current_forum $vbulletin->forumcache["$current_forum[parentid]"];
            }
        }

        if (!
$forum_active_cache["$simthread[forumid]"])
        {
            continue;
        }

        
$fperms fetch_permissions($simthread['forumid']);
        if ((
$fperms $vbulletin->bf_ugp_forumpermissions['canview']) AND
            ((
$fperms $vbulletin->bf_ugp_forumpermissions['canviewothers']) OR ($vbulletin->userinfo['userid'] != AND $simthread['postuserid'] == $vbulletin->userinfo['userid']))

        )
        {
            
// format thread preview if there is one
            
if ($ignore["$simthread[postuserid]"])
            {
                
$simthread['preview'] = '';
            }
            else if (isset(
$simthread['preview']) AND $vbulletin->options['threadpreview'] > 0)
            {
                
$simthread['preview'] = strip_quotes($simthread['preview']);
                
$simthread['preview'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbcode($simthread['preview'], falsetrue), $vbulletin->options['threadpreview']));
            }

            
$simthread['lastreplydate'] = vbdate($vbulletin->options['dateformat'], $simthread['lastpost'], true);
            
$simthread['lastreplytime'] = vbdate($vbulletin->options['timeformat'], $simthread['lastpost']);

            if (
$simthread['prefixid'])
            {
                
$simthread['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_$simthread[prefixid]_title_plain"]);
                
$simthread['prefix_rich'] = $vbphrase["prefix_$simthread[prefixid]_title_rich"];
            }
            else
            {
                
$simthread['prefix_plain_html'] = '';
                
$simthread['prefix_rich'] = '';
            }

            
$simthread['title'] = fetch_censored_text($simthread['title']);

            (
$hook vBulletinHook::fetch_hook('showthread_similarthreadbit')) ? eval($hook) : false;

            eval(
'$similarthreadbits .= "' fetch_template('showthread_similarthreadbit') . '";');
        }
    }
    if (
$similarthreadbits)
    {
        eval(
'$similarthreads = "' fetch_template('showthread_similarthreads') . '";');
    }
    else
    {
        
$similarthreads '';
    }
    unset(
$similarthreadbits);
}
else
{
    
$similarthreads '';

I placed it at postbit_display_start, postbit_display_complete, global_start.
Tried all 3 with no results.

Same thing with the templates

PHP Code:
$globaltemplates = array(
    
'showthread_similarthreadbit',
    
'showthread_similarthreads',
); 

This is how I tried to call the templates from POSTBIT

$similarthreads
$similarthreadbit

but nothing happens.

What am I doing wrong?
Reply With Quote
  #7  
Old 12-01-2008, 03:20 PM
zglows zglows is offline
 
Join Date: Oct 2007
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is it at least possible to make?
Reply With Quote
  #8  
Old 12-01-2008, 03:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes it's possible since you can see they do it here in the Modification forums.

You should be using the cache_templates hook for your templates.

I would have tried to use a hook location at the beginning of showthread and then spit it out after the first postbit.
Reply With Quote
Reply

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 04:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10334 seconds
  • Memory Usage 2,294KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete