vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to display latest threads in forumhome? (https://vborg.vbsupport.ru/showthread.php?t=74078)

zurih 01-09-2005 06:04 PM

How to display latest threads in forumhome?
 
I created an empty block in forumhome. How can I put there latest threads?

thanks

kall 01-09-2005 08:49 PM

Quote:

Originally Posted by zurih
I created an empty block in forumhome. How can I put there latest threads?

thanks

SBYP (Search Before You Post) - https://vborg.vbsupport.ru/showthrea...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

cinq 01-10-2005 07:48 AM

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?

cinq 01-10-2005 08:06 AM

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?

cinq 01-10-2005 12:25 PM

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...

PHP Code:

$threads true;
$thread['title'] = fetch_censored_text(fetch_trimmed_title(unhtmlspecialchars($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_bbcode(fetch_censored_text($thread['preview']), falsetrue), $vboptions['threadpreview']));
$thread['replycount'] = vb_number_format($thread['replycount']);
$thread['views'] = vb_number_format($thread['views']); 


cinq 01-10-2005 01:05 PM

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:

PHP Code:

// 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(unhtmlspecialchars($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_bbcode(fetch_censored_text($thread['preview']), falsetrue), $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

cinq 01-10-2005 01:26 PM

No guarantees this will work.

Using $thread[message] and $thread[forumname] in the templates.

Code in index.php you can try:

PHP Code:

// 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(unhtmlspecialchars($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_bbcode(fetch_censored_text($threa  d['preview']), falsetrue), $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
Code:

Parse error: parse error, unexpected T_STRING in /forums/index.php on line 456
the line is

PHP Code:

$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
Code:

$thread['message'] = htmlspecialchars_uni(fetch_trimmed_title(strip_bbcode(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


All times are GMT. The time now is 01:09 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01514 seconds
  • Memory Usage 1,830KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete