Here is the code used in my portal for the news
PHP Code:
// ######################### PROCESS NEWS ############################
// standard news block
if (($vbindex['options'] & VBI_SHOWNEWS) && !($vbindex['options'] & VBI_VBWAR) && !EXTRA_PAGE && $_REQUEST['action'] != 'shoutbox') {
$getnews = $DB_site->query("
## GET NEWS ##
SELECT thread.*,thread.iconid AS threadiconid, threadpost.pagetext AS pagetext,
threadpost.attach AS attachcount,
".iif($vbindex['options'] & VBI_SHOWNEWSAVATAR, 'avatarpath, NOT ISNULL(avatardata) AS customavatar, user.avatarrevision, customavatar.dateline AS customdateline,')."
".iif(($vbindex['options'] & VBI_SUBNEWS) AND $bbuserinfo['userid'], 'NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed,')."
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."user AS user ON (thread.postuserid = user.userid)
LEFT JOIN ".TABLE_PREFIX."post AS threadpost ON (thread.firstpostid = threadpost.postid)
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
".iif($vbindex['options'] & VBI_SHOWNEWSAVATAR, '
LEFT JOIN '.TABLE_PREFIX.'customavatar AS customavatar ON (customavatar.userid = user.userid)
LEFT JOIN '.TABLE_PREFIX.'avatar AS avatar ON (avatar.avatarid = user.avatarid)'
)."
".iif(($vbindex['options'] & VBI_SUBNEWS) AND $bbuserinfo['userid'], "
LEFT JOIN ".TABLE_PREFIX."subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = $bbuserinfo[userid])"
)."
WHERE forumid IN ($vbindex[newsfid])
AND deletionlog.primaryid IS NULL
AND forumid NOT IN (".implode(',', $limitfids).")
AND thread.open <> 10
AND thread.visible = '1'
$globalignore
$ignorelist
ORDER BY ".iif($vbindex['options'] & VBI_STICKYNEWS, 'thread.sticky DESC,', '')." thread.dateline DESC
LIMIT $vbindex[newsposts]");
while($news = $DB_site->fetch_array($getnews)) {
$news['title'] = fetch_censored_text($news['title']);
$news['time'] = vbdate($vboptions['timeformat'], $news['dateline']);
$news['date'] = vbdate($vboptions['dateformat'], $news['dateline'], 1);
$news['musername'] = fetch_musername($news, 'displaygroupid', 'postusername');
$news['attachcount'] = vb_number_format($news['attachcount']);
$news['replycount'] = vb_number_format($news['replycount']);
if ($news['iconid']) {
$news['showicon'] = true;
$news['threadiconpath'] = &$iconcache["$news[threadiconid]"]['iconpath'];
$news['threadicontitle'] = &$iconcache["$news[threadiconid]"]['title'];
} elseif (!empty($vboptions['showdeficon'])) {
$news['showicon'] = true;
$news['threadiconpath'] = $vboptions['showdeficon'];
$news['threadicontitle'] = $vbphrase['default'];
}
// ## CENSOR NEWS AND PARSE vB CODE ##
$news['pagetext'] = fetch_censored_text(parse_bbcode(strip_bbcode(fetch_trimmed_title($news['pagetext'], 394), true, true), $news['forumid'], 1));
// ## GET POSTERS AVATAR ##
$news['avatar'] = false;
if ($vbindex['options'] & VBI_SHOWNEWSAVATAR) {
if (!isset($avatarcache["$news[postuserid]"])) {
if ($news['customavatar']) {
if ($vboptions['usefileavatar']) {
$news['avatarurl'] = "$vboptions[avatarurl]/avatar$news[postuserid]_$news[avatarrevision].gif";
} else {
$news['avatarurl'] = "$vboptions[bburl]/image".SCRIPT_EXTENSION."?userid=$news[postuserid]&dateline=$news[customdateline]";
}
$news['avatar'] = true;
$avatarcache["$news[postuserid]"] = $news['avatarurl'];
DEVDEBUG("cached avatar for userid $news[postuserid]");
} elseif (!empty($news['avatarpath'])) {
$news['avatarurl'] = $vboptions['bburl'].'/'.$news['avatarpath'];
$news['avatar'] = true;
$avatarcache["$news[postuserid]"] = $news['avatarurl'];
DEVDEBUG("cached avatar for userid $news[postuserid]");
} elseif (!empty($vbindex['useravatar'])) { // we have a default av specified
$avatarurl = $vbindex['useravatar'];
$avatarcache["$bbuserinfo[userid]"] = $avatarurl;
$news['avatar'] = true;
}
} else {
$news['avatar'] = true;
$news['avatarurl'] = $avatarcache["$news[postuserid]"];
}
}
eval("\$home[news] .= \"".fetch_template('vbindex_newsbit')."\";");
}
// memory saving
unset($news);
$DB_site->free_result($getnews);
}
// if vBwar is enabled then show that instead
if ((($vbindex['options'] & VBI_VBWAR) && !($vbindex['options'] & VBI_SHOWNEWS)) && !EXTRA_PAGE && $_REQUEST['action'] != 'shoutbox') {
require_once('./vnews.php');
}
Can anyone help me make this work?