I use this
mod to display the threads with the most recent posts after the header.
I am trying to alter it to include a summary of the first post in the thread. It is turning out to be harder then I thought. I tried to do it myself but it won't work.
Here is the plugin code with the alterations I have tried.
I have bolded my additions
I would love to even get some tips on what I am doing wrong
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="btrecentxthreads" active="1">
<title>BT - Recent X Threads</title>
<description>Display recent x threads or posts on forumhome.</description>
<version>4.00</version>
<url>http://www.metalturkiye.com</url>
<versioncheckurl />
<dependencies>
<dependency dependencytype="vbulletin" minversion="4.0.0" maxversion="4.1.99" />
</dependencies>
<codes>
</codes>
<templates>
<template name="bts_recentxposts.css" templatetype="template" date="114473878901" username="BlackThorn" version="4.0.7"><![CDATA[.bttable {
font-weight: bold;
text-align: center;
}
.bttable td {
padding:12px;
vertical-align:top;
border-left:1px solid #cedfeb;
border-right:1px solid #cedfeb;
border-bottom:1px solid #cedfeb;
}
.bttable .alt1 {
background-color:rgb(255,255,255);
}
.bttable .alt2 {
background-color:rgb(240,242,250);
}]]></template>
<template name="bts_recentxposts" templatetype="template" date="1218493517" username="BlackThorn" version="4.0.7"><![CDATA[<br />
<div id="latestxthreadslist" class="block bttable">
<h2 class="blockhead"><a href="search.php?{vb:raw session.sessionurl}do=getnew">{vb:rawphrase statistics}</a></h2>
<table id="bttable td" width="100%">
<tr>
<td class="blocksubhead" width="40%" nowrap="nowrap">{vb:rawphrase threads}</td>
<td width="30%" align="center" class="blocksubhead" nowrap="nowrap">{vb:rawphrase forums}</td>
<td width="20%" align="center" class="blocksubhead" nowrap="nowrap">Date & Time</td>
<td width="10%" align="center" class="blocksubhead" nowrap="nowrap">{vb:rawphrase replies}</td>
<td width="10%" align="center" class="blocksubhead" nowrap="nowrap">{vb:rawphrase views}</td>
</tr>
{vb:raw btecentxthreads_bits}
</table>
</div>]]></template>
<template name="bts_recentxposts_bit" templatetype="template" date="1218492313" username="BlackThorn" version="4.0.7"><![CDATA[<tr>
<td class="alt2">
<vb:if condition="$getposts_thread[newpost]">
<a href="showthread.php?{vb:raw session.sessionurl}goto=newpost&t={vb:raw getposts_thread.threadid}" id="thread_gotonew_{vb:raw getposts_thread.realthreadid}"><img class="inlineimg" src="images/statusicon/post_new.gif" alt="{vb:rawphrase go_to_first_new_post}" border="0" /></a></vb:if>
{vb:raw getposts_thread.prefix_rich}
<a href="showthread.php?{vb:raw session.sessionurl}t={vb:raw getposts_thread.threadid}{vb:raw getposts_thread.highlight}" id="thread_title_{vb:raw getposts_thread.realthreadid}"<vb:if condition="$getposts_thread[newpost]"> style="font-weight:bold"</vb:if> title="{vb:raw getposts_thread.titletrimmed}">{vb:raw getposts_thread.titletrimmed}</a>
[B]<div style="clear:both; border:1px dashed #c4c4c4; padding:10px; margin:10px 5px 5px 5px; background-color:#fefdf2;">
{vb:raw getpost_preview.pagetext}
</div>[/B]
</td>
<td align="center" class="alt1"><a href="forumdisplay.php?{vb:raw session.sessionurl}f={vb:raw getposts_thread.forumid}">{vb:raw getposts_thread.forumtitle}</a>
</td>
<td class="alt2" align="center">
{vb:raw getposts_thread.lastpostdate}
<vb:if condition="!$show['detailedtime']">
{vb:raw getposts_thread.lastposttime}</vb:if>
</td>
<td class="alt1" align="center">
<a href="misc.php?do=whoposted&t={vb:raw getposts_thread.threadid}" onclick="who({vb:raw getposts_thread.threadid}); return false;">
{vb:raw getposts_thread.replycount}</a>
</td>
<td class="alt2" align="center">
{vb:raw getposts_thread.views}
</td>
</tr>]]></template>
</templates>
<stylevardfns>
</stylevardfns>
<stylevars>
</stylevars>
<plugins>
<plugin active="1" executionorder="5">
<title>BT - Latest x threads cache</title>
<hookname>cache_templates</hookname>
<phpcode><![CDATA[if ($show['latestxposts'])
{
$cache[] = 'latestxposts' ;
$cache[] = 'latestxposts_bit' ;
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="5">
<title>BT - Latest x threads core codes</title>
<hookname>forumhome_complete</hookname>
<phpcode><![CDATA[// BT - BlackThorn Coding 2010
// $getpost_preview.(getposts_thread.firstpostid)
// BT - Latest x threads and posts core codes
// BT - Latest x threads and posts vBulletin 4.0.7
// BT - Latest (5 or X) threads and posts on Forumhome
// START - BT - Latest x threads and posts core codes
// BT - Global mode ON
global $vbulletin;
// BT - Display record mode ON
$displayrecords = intval($vbulletin->options['latestXposts_displayrecords_forumhome']);
if ($displayrecords <= 0)
{
$displayrecords = '';
}
if ($vbulletin->options['latestXposts_excludedforums'] !== '') {
$excludedforums = ',' . $vbulletin->options['latestXposts_excludedforums'];
}
// BT - Forums Permissions
$forumpermissions = array();
foreach($vbulletin->forumcache AS $forum) {
$forumpermissions[$forum["forumid"]] = fetch_permissions($forum['forumid']);
if (!($forumpermissions[$forum["forumid"]] & $vbulletin->bf_ugp_forumpermissions['canview']) AND !$vbulletin->options['showprivateforums']) {
$excludedforums = $excludedforums . ',' . $forum['forumid'];
}
// BT - Filter out deletion notices if can't be seen.
if ($forumpermissions[$forum["forumid"]] & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] OR can_moderate($forum['forumid'])){
$deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')";
}
else
{
$deljoin = '';
}
}
unset($forum);
// BT - Get rid of initial comma
$excludedforums = substr($excludedforums, 1);
if ($excludedforums != "") {
$excludedforums = "AND thread.forumid NOT IN ($excludedforums)";
}
$threadchars = $vbulletin->options['latestXposts_threadchars'];
if ($threadchars <= 0) {
$threadchars = $vbulletin->options['lastthreadchars'];
}
$userchars = $vbulletin->options['latestXposts_userchars'];
if ($threadchars <= 0) {
$threadchars = $vbulletin->options['lastthreadchars'];
}
[B]//CW - Post Preview information
//$getpost_previews = $db->query_read("SELECT post.postid, post.pagetext")
//LEFT JOIN post AS post ON ( thread.firstpostid = post.postid )
//while ($getpost_preview = $db->fetch_array($getpostpreviews))
//$pagetext = $db->query_read("SELECT post.pagetext FROM post WHERE post.postid = //$firstpostid)
//$pagetext = $db->query_read("SELECT post.postid, post.pagetext, thread.firstpostid //LEFT JOIN
$getpost_preview = $db->query_read("SELECT post.pagetext FROM post AS post WHERE postid = $firstpostid)
while ($getpost_preview = $db->fetch_array($getpost_preview))[/B]
// BT - DB INFORMATIONS, WARNING! NEVER CHANGE ANY CODE HERE!
$getposts_threads = $db->query_read("SELECT thread.threadid, thread.title, thread.lastpost, thread.firstpostid, thread.forumid, thread.attach, thread.taglist, thread.prefixid, thread.replycount, thread.lastposter, thread.dateline, IF(views<=replycount, replycount+1, views) AS views, thread.visible, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid " . iif($deljoin, ", NOT ISNULL(deletionlog.primaryid) AS isdeleted, deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason") . "
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.username = thread.lastposter) $deljoin
WHERE NOT ISNULL(thread.threadid)
$excludedforums
" . iif(!$deljoin, "AND thread.visible <> 2") . "
ORDER BY lastpost DESC LIMIT 0, $displayrecords");
// BT - THE END DB QUERIES.
while ($getposts_thread = $db->fetch_array($getposts_threads))
{
// BT - User avatars information
require_once('./includes/functions_user.php');
if($getposts_thread[userid])
$getposts_thread[avatarurl] = fetch_avatar_url($getposts_thread[userid]);
if (!$getposts_thread[avatarurl]) {
$getposts_thread[avatarurl] = $stylevar['imgdir_misc'] . '/images/misc/unknown.gif';
} else {
$getposts_thread[avatarurl] = $vbulletin->options['bburl'] . '/' .
$getposts_thread[avatarurl][0];
}
// BT - Threads Title Trimmeds.
$getposts_thread[title] = unhtmlspecialchars($getposts_thread[title]);
if ($threadchars > 0) {
if (strlen($getposts_thread[title]) > $threadchars)
{
$getposts_thread[titletrimmed] = substr($getposts_thread[title], 0, strrpos(substr($getposts_thread[title], 0, $threadchars), ' ')) . '...';
}
else
{
$getposts_thread[titletrimmed] = $getposts_thread[title];
}
}
if ($getposts_thread[lastpost] > $vbulletin->userinfo['lastvisit'])
{
$getposts_thread[newpost] = true;
}
// BT - Thread last replies date/times.
$getposts_thread['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $getposts_thread['lastpost'], true);
$getposts_thread['lastposttime'] = vbdate($vbulletin->options['timeformat'], $getposts_thread['lastpost']);
// BT - Threads forums title.
if (empty($getposts_thread['forumtitle']))
{
$getposts_thread['forumtitle'] = $vbulletin->forumcache["$getposts_thread[forumid]"]['title'];
}
if ($getposts_thread['lastpost'] > $lastread)
{
if ($vbulletin->options['threadmarking'] AND $getposts_thread['threadread'])
{
$threadview = $getposts_thread['threadread'];
}
else
{
$threadview = intval(fetch_bbarray_cookie('thread_lastview', $getposts_thread['threadid']));
}
if ($getposts_thread['lastpost'] > $threadview)
{
$getposts_thread['statusicon'] .= '_new';
$show['gotonewpost'] = true;
}
else
{
$newthreads--;
$show['gotonewpost'] = false;
}
}
else
{
$show['gotonewpost'] = false;
}
// BT - Threads has attachments?!
if ($getposts_thread['attach'] > 0)
{
$show['paperclip'] = true;
$getposts_thread['checkbox_value'] += THREAD_FLAG_ATTACH;
}
// BT - Threads has tags?!
$show['taglist'] = ($vbulletin->options['threadtagging'] AND !empty($getposts_thread['taglist']));
// BT - Threads has prefix?!
if ($getposts_thread['prefixid'])
{
$getposts_thread['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_$getposts_thread[prefixid]_title_plain"]);
$getposts_thread['prefix_rich'] = $vbphrase["prefix_$getposts_thread[prefixid]_title_rich"];
}
else
{
$getposts_thread['prefix_plain_html'] = '';
$getposts_thread['prefix_rich'] = '';
}
if ($getposts_thread[isdeleted])
{
$getposts_thread[isdeleted] = true;
}
if ($userchars > 0) {
if (strlen($getposts_thread[username]) > $userchars)
{
$getposts_thread[username] = substr($getposts_thread[username], 0, $userchars) . '...';
}
else
{
$getposts_thread[username] = $getposts_thread[username];
}
}
$getposts_member[musername] = fetch_musername($getposts_thread);
// BT - Template Registereds.
$templater = vB_Template::create('bts_recentxposts_bit');
$templater->register('getposts_thread',$getposts_thread);
$templater->register('getposts_member',$getposts_member);
$templater->register('userchars',$userchars);
$btecentxthreads_bits .= trim($templater->render()).' ';
}
// BT - Template Registereds.
$templater = vB_Template::create('bts_recentxposts');
$templater->register('latestXposts',$latestXposts);
$templater->register('btecentxthreads_bits',$btecentxthreads_bits);
$btecentxthreads_bits = $templater->render();
// BT - Hook Location on FORUMHOME
$latestXposts_man['latestXposts'] = $templater->render();
vB_Template::preRegister('navbar', $latestXposts_man);
vB_Template::preRegister('footer', $latestXposts_man);
vB_Template::preRegister('FORUMHOME', $latestXposts_man);
if ($_REQUEST['do']!='latestXposts')
{
switch ($vbulletin->options['latestXposts_fhome_loc'])
{
case 0: break;
case 1: $ad_location['global_below_navbar'] .= $btecentxthreads_bits; break;
case 2: $template_hook['forumhome_below_forums'] .= $btecentxthreads_bits; break;
case 3: $footer = $btecentxthreads_bits.$footer; break;
}
}
// BT - Display Mod Mode ON
$show['latestXposts'] = true;
// BT - The End core codes]]></phpcode>
</plugin>
</plugins>
<phrases>
<phrasetype name="GLOBAL" fieldname="global">
<phrase name="statistics" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Today's Active Recent Threads]]></phrase>
<phrase name="latestXposts_put_below_navbar"><![CDATA[Below Navbar]]></phrase>
<phrase name="latestXposts_put_below_forums"><![CDATA[Below Forums]]></phrase>
<phrase name="latestXposts_put_above_footer"><![CDATA[Above Footer]]></phrase>
<phrase name="latestXposts_mainbox_noauto"><![CDATA[No auto-insertion]]></phrase>
</phrasetype>
<phrasetype name="vBulletin Settings" fieldname="vbsettings">
<phrase name="setting_latestXposts_displayrecords_forumhome_desc" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Specify the default amount of stats to show on the expanded Top 'X' Stats page.]]></phrase>
<phrase name="setting_latestXposts_displayrecords_forumhome_title" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Number Of Stats To Show (Forumhome)]]></phrase>
<phrase name="setting_latestXposts_excludedforums_desc" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Here you can specify what forums you want to exclude from the latest replies column. Seperate each forum with a ,<br /><br />e.g 1,5,8]]></phrase>
<phrase name="setting_latestXposts_excludedforums_title" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Excluded Forums]]></phrase>
<phrase name="setting_latestXposts_threadchars_desc" date="0" username="BlackThorn" version="4.0.7"><![CDATA[This value will chop the title of the latest replies thread title posted down to a specific number of characters for its display on the stats page.<br /><br />A value of 0 will use the "$vbulletin->options['lastthreadchars']" instead.]]></phrase>
<phrase name="setting_latestXposts_threadchars_title" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Latest Replies Thread Title Displayed Characters]]></phrase>
<phrase name="setting_latestXposts_userchars_desc" date="0" username="BlackThorn" version="4.0.7"><![CDATA[This value will chop the usernames down to a specific number of characters.<br /><br />A value of 0 will not truncate the usernames at all.]]></phrase>
<phrase name="setting_latestXposts_userchars_title" date="0" username="BlackThorn" version="4.0.7"><![CDATA[Usernames Displayed Characters]]></phrase>
<phrase name="setting_latestXposts_fhome_loc_desc"><![CDATA[Main recent x threads on forumhome]]></phrase>
<phrase name="setting_latestXposts_fhome_loc_title"><![CDATA[Show recent x threads on pages (OPTIONAL)]]></phrase>
<phrase name="settinggroup_latestXposts" date="0" username="BlackThorn" version="4.0.7"><![CDATA[BT - Today's Recent X Threads-Posts]]></phrase>
</phrasetype>
</phrases>
<options>
<settinggroup name="latestXposts" displayorder="65535">
<setting varname="latestXposts_displayrecords_forumhome" displayorder="10">
<datatype>number</datatype>
<defaultvalue>10</defaultvalue>
</setting>
<setting varname="latestXposts_excludedforums" displayorder="20">
<datatype>free</datatype>
<defaultvalue>0</defaultvalue>
</setting>
<setting varname="latestXposts_threadchars" displayorder="30">
<datatype>number</datatype>
<defaultvalue>0</defaultvalue>
</setting>
<setting varname="latestXposts_userchars" displayorder="40">
<datatype>number</datatype>
<defaultvalue>0</defaultvalue>
</setting>
<setting varname="latestXposts_fhome_loc" displayorder="50">
<datatype>free</datatype>
<optioncode><![CDATA[select:piped
0|latestXposts_mainbox_noauto
1|latestXposts_put_below_navbar
2|latestXposts_put_below_forums
3|latestXposts_put_above_footer]]></optioncode>
<defaultvalue>2</defaultvalue>
</setting>
</settinggroup>
</options>
<helptopics>
</helptopics>
<cronentries>
</cronentries>
<faqentries>
</faqentries>
</product>