PDA

View Full Version : Please help me call this template!


zglows
11-29-2008, 08:56 AM
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.

ReCom
11-29-2008, 10:00 AM
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?

zglows
11-29-2008, 11:15 AM
I want $similarthreads in postbit so I can display similar threads after the first post.
Then I'll make them display just once.

ReCom
11-29-2008, 11:45 AM
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.

SEOvB
11-29-2008, 11:57 AM
what about using global_start?

zglows
11-29-2008, 01:37 PM
Thanks for your replies guys

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

// ************************************************** *******************************
// 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_similarthrea d_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'] != 0 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_bbc ode($simthread['preview'], false, true), $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_similarthrea dbit')) ? 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

$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?

zglows
12-01-2008, 03:20 PM
is it at least possible to make?

Lynne
12-01-2008, 03:34 PM
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.