View Full Version : How to display latest threads in forumhome?
zurih
01-09-2005, 06:04 PM
I created an empty block in forumhome. How can I put there latest threads?
thanks
I created an empty block in forumhome. How can I put there latest threads?
thanks
SBYP (Search Before You Post) - https://vborg.vbsupport.ru/showthread.php?t=60544&highlight=latest+threads
zurih
01-10-2005, 07:32 AM
yes but I want something that looks like Featured Hack, but with latest threads.
https://vborg.vbsupport.ru/showthread.php?t=73507
thanks
Follow Kall's link, can make it look like the forum home in my Featured Hack just by changing templates here and there.
zurih
01-10-2005, 08:04 AM
thanks! I installed the featured hack already. I want to keep it.
and in addition I'll add the latest threads.
Do u know how its possible to do something like: 5 featured threads, and 5 latest threads.
Possible?
yes why not, you just need to add in some code in the index.php file ( or portal.php if you are using the portal version ).
If you need help with that let me know.
zurih
01-10-2005, 08:39 AM
thanks! I think I got it :)
zurih
01-10-2005, 09:47 AM
ok i have two problems
the latest threads titles are displayed. but the message itself is not. and nor the forum of the thread.
I used $thread[message] and $thread[forumname]
:ermm:
zurih
01-10-2005, 12:18 PM
cinq? anyone?
What is the code you added ?
zurih
01-10-2005, 12:39 PM
in index.php I didnt add anything
in the template I added $thread[message] and $thread[forumname]
there is something to add I guess
this is the code from index.php...
$threads = true;
$thread['title'] = fetch_censored_text(fetch_trimmed_title(unhtmlspec ialchars($thread['title']), 22));
$thread['date'] = vbdate($vboptions['dateformat'], $thread['lastpost'], 1);
$thread['time'] = vbdate($vboptions['timeformat'], $thread['lastpost']);
$thread['preview'] = preg_replace('#\[quote(=("|"|\'|).*\\2)?\](.*)\[/quote\]#siU', '', $thread['preview']);
$thread['preview'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbc ode(fetch_censored_text($thread['preview']), false, true), $vboptions['threadpreview']));
$thread['replycount'] = vb_number_format($thread['replycount']);
$thread['views'] = vb_number_format($thread['views']);
That's the only added code in index.php ?
There is no $thread[message] and $thread[forumname], thats why they don't show on the template as well.
zurih
01-10-2005, 01:18 PM
what excatly should I add? can u write down the whole lines?
here is the whole code added for Latest Treads:
// START HACK 'Latest Threads On Forum Home'
// #################### PROCESS LATEST THREADS #######################
// fetch the permissions for each forum
$forumperms = array();
foreach($forumcache AS $forum) {
$forumperms["$forum[forumid]"] = fetch_permissions($forum['forumid']);
// ## HIDE FORUMS WITHOUT THE CANVIEW OR CANVIEWOTHERS PERMISSION ##
if (!($forumperms["$forum[forumid]"] & CANVIEW) || !($forumperms["$forum[forumid]"] & CANVIEWOTHERS)) {
$limitfids .= ','.$forum['forumid'];
}
}
unset($forum);
if ($vboptions['threadpreview'] > 0) {
$previewfield = ', post.pagetext AS preview';
$previewjoin = 'LEFT JOIN '.TABLE_PREFIX.'post AS post ON(post.postid = thread.firstpostid)';
}
$getthreads = $DB_site->query("
## GET LATEST THREADS ##
SELECT thread.*,thread.iconid AS threadiconid $previewfield
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
$previewjoin
WHERE open = '1'
AND forumid NOT IN (0$limitfids)
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
ORDER BY lastpost
DESC LIMIT 5");
while($thread = $DB_site->fetch_array($getthreads)) {
$threads = true;
$thread['title'] = fetch_censored_text(fetch_trimmed_title(unhtmlspec ialchars($thread['title']), 22));
$thread['date'] = vbdate($vboptions['dateformat'], $thread['lastpost'], 1);
$thread['time'] = vbdate($vboptions['timeformat'], $thread['lastpost']);
$thread['preview'] = preg_replace('#\[quote(=("|"|\'|).*\\2)?\](.*)\[/quote\]#siU', '', $thread['preview']);
$thread['preview'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbc ode(fetch_censored_text($thread['preview']), false, true), $vboptions['threadpreview']));
$thread['replycount'] = vb_number_format($thread['replycount']);
$thread['views'] = vb_number_format($thread['views']);
// thread icon
$show['icon'] = false;
$icon = fetch_iconinfo($thread['iconid']);
if (is_array($icon)) {
$show['icon'] = true;
$thread['threadiconpath'] = $icon['iconpath'];
$thread['threadicontitle'] = $icon['title'];
}
// show goto new post
$show['firstnew'] = false;
$bbforumview = fetch_bbarray_cookie('forum_view', $thread['forumid']);
if ($bbforumview > $bbuserinfo['lastvisit']) {
$lastread = $bbforumview;
} else {
$lastread = $bbuserinfo['lastvisit'];
}
if ($thread['lastpost'] > $lastread) {
$threadview = fetch_bbarray_cookie('thread_lastview', $thread['threadid']);
if ($thread['lastpost'] > $threadview) {
$show['firstnew'] = true;
$show['icon'] = false;
}
}
exec_switch_bg();
eval("\$threadbits .= \"".fetch_template('forumhome_latestthreadbit')."\";");
}
if ($threads) {
$show['latestthreads'] = true;
}
// memory saving
unset($thread, $threads);
$DB_site->free_result($getthreads);
// END HACK 'Latest Threads On Forum Home'
thanks
No guarantees this will work.
Using $thread[message] and $thread[forumname] in the templates.
Code in index.php you can try:
// START HACK 'Latest Threads On Forum Home'
// #################### PROCESS LATEST THREADS #######################
// fetch the permissions for each forum
$forumperms = array();
foreach($forumcache AS $forum) {
$forumperms["$forum[forumid]"] = fetch_permissions($forum['forumid']);
// ## HIDE FORUMS WITHOUT THE CANVIEW OR CANVIEWOTHERS PERMISSION ##
if (!($forumperms["$forum[forumid]"] & CANVIEW) || !($forumperms["$forum[forumid]"] & CANVIEWOTHERS)) {
$limitfids .= ','.$forum['forumid'];
}
}
unset($forum);
if ($vboptions['threadpreview'] > 0) {
$previewfield = ', post.pagetext AS preview';
$previewjoin = 'LEFT JOIN '.TABLE_PREFIX.'post AS post ON(post.postid = thread.firstpostid)';
}
$getthreads = $DB_site->query("
## GET LATEST THREADS ##
SELECT thread.*, forum.title, thread.iconid AS threadiconid $previewfield
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
LEFT JOIN ".TABLE_PREFIX."forum ON thread.forumid = forum.forumid
$previewjoin
WHERE open = '1'
AND forumid NOT IN (0$limitfids)
AND thread.visible = '1'
AND deletionlog.primaryid IS NULL
ORDER BY lastpost
DESC LIMIT 5");
while($thread = $DB_site->fetch_array($getthreads)) {
$threads = true;
$thread['forumname'] = $thread['forum.title'];
$thread['thread.title'] = fetch_censored_text(fetch_trimmed_title(unhtmlspec ialchars($thread['title']), 22));
$thread['date'] = vbdate($vboptions['dateformat'], $thread['lastpost'], 1);
$thread['time'] = vbdate($vboptions['timeformat'], $thread['lastpost']);
$thread['preview'] = preg_replace('#\[quote(=("|"|\'|).*\\2)?\](.*)\[/quote\]#siU', '', $thread['preview']);
$thread['message'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbc ode(fetch_censored_text($threa d['preview']), false, true), $vboptions['threadpreview']));
$thread['replycount'] = vb_number_format($thread['replycount']);
$thread['views'] = vb_number_format($thread['views']);
// thread icon
$show['icon'] = false;
$icon = fetch_iconinfo($thread['iconid']);
if (is_array($icon)) {
$show['icon'] = true;
$thread['threadiconpath'] = $icon['iconpath'];
$thread['threadicontitle'] = $icon['title'];
}
// show goto new post
$show['firstnew'] = false;
$bbforumview = fetch_bbarray_cookie('forum_view', $thread['forumid']);
if ($bbforumview > $bbuserinfo['lastvisit']) {
$lastread = $bbforumview;
} else {
$lastread = $bbuserinfo['lastvisit'];
}
if ($thread['lastpost'] > $lastread) {
$threadview = fetch_bbarray_cookie('thread_lastview', $thread['threadid']);
if ($thread['lastpost'] > $threadview) {
$show['firstnew'] = true;
$show['icon'] = false;
}
}
exec_switch_bg();
eval("\$threadbits .= \"".fetch_template('forumhome_latestthreadbit')."\";");
}
if ($threads) {
$show['latestthreads'] = true;
}
// memory saving
unset($thread, $threads);
$DB_site->free_result($getthreads);
// END HACK 'Latest Threads On Forum Home'
zurih
01-10-2005, 01:53 PM
I'm gettin an error
Parse error: parse error, unexpected T_STRING in /forums/index.php on line 456
the line is
$thread['forumname'] = $thread['forum.title'];
and if I remove this line i'm getting database error
The thread message is working! :)
I added just this line
$thread['message'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbc ode(fetch_censored_text($thread['preview']), false, true), $vboptions['threadpreview']));
just the forum name left
zurih
01-10-2005, 06:15 PM
instead of preview in [message] I used pagetext as used in featured threads. it works smootly.
I resolved everything exept the forum name.
I'm getting database errors when trying to insert those code lines.
if anyone can help me resolve this I would really appreciate it.
thanks in advance
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.