vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - [WIDGET] Recent Threads (https://vborg.vbsupport.ru/showthread.php?t=236404)

cory_booth 02-19-2010 10:00 PM

[WIDGET] Recent Threads
 
1 Attachment(s)
In an attempt at mirroring an old ASP website I used to have, I modified the recent threads display to show a bit more information in a bit more compressed format.

Feel free to use/hack/slash this code for your own needs...

Navigate to AdminCP -> CMS -> Widgets.
Create a PHP Type Widget and paste the below code.

READ BELOW THE CODE FOR AN UPDATE

PHP Code:

ob_start();
global 
$vbulletin$db;
//Begin Thread Counts 
$toutput=''
$recent_threads $vbulletin->db->query_read(
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle
FROM  " 
TABLE_PREFIX "thread AS thread 
LEFT JOIN  " 
TABLE_PREFIX "forum AS forum ON ( forum.forumid = thread.forumid ) 
WHERE NOT ISNULL(threadid) AND visible = '1' AND open!='10' 
ORDER BY lastpost DESC 
LIMIT 0, 10 
"
); 
$i 0
while (
$recent_thread $db->fetch_array($recent_threads)) 

$i++;
if (!
in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) { 
if (
$i 1) {$class='alt1';} else {$class='alt2';} 
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]); 
$recent_thread[lastpostdate] = vbdate('M jS'$recent_thread[lastpost], 1); 
$recent_thread[lastposttime] = vbdate($vbulletin->options['timeformat'], $recent_thread[lastpost]); 
$toutput .='<tr><td class="'.$class.'" align="left"><b><font color="#98B5E2" size="1" face="verdana,arial"><a href="showthread.php?t='.    $recent_thread[threadid].'">'.    $recent_thread[title].'</a></font></b><br/>'
$toutput .='<b><span style="color: #E1E1E2"><font size="1" face="verdana,arial">Last Post By: <a href="member.php?u='.$recent_thread[lastposterid].'">'.$recent_thread[lastposter].'</a></font><br/></span></b>'
$toutput .='<font size="1" face="verdana,arial">Forum: <a href="forumdisplay.php?f='.$recent_thread[forumid].'">'.$recent_thread[forumtitle].'</a> | Replies: '.$recent_thread[replycount].'</font><br/>'
$toutput .='<font size="1" face="verdana,arial">Posted: <strong>'.$recent_thread[lastpostdate].'</strong> at: <strong>'.    $recent_thread[lastposttime].'</strong></font><hr/></td></tr>'

}
//End Thread Counts 

//Sidebar - Begin Forum Threads
$sb_threads '
<table class="tborder" cellpadding="'
.$stylevar[cellpadding].'" cellspacing="'.$stylevar[cellspacing].'" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"></td> </tr> </thead> <tbody> <div class="smallfont"> <tr> <td>
'
.$toutput.'
</td> </tr> </div> </tbody> </table>
'
;
//Sidebar - End Forum Threads
echo $sb_threads;
$db->free_result($recent_threads);
$output=ob_get_contents();
ob_end_clean(); 


Updated to reflect contribution from Inflikted:
https://vborg.vbsupport.ru/showpost....7&postcount=25

Be SURE to update the following line:if (!in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))), to group the forumids you wish to NOT have included in the query results.

tort 02-20-2010 02:59 PM

Where do you put this in?

cory_booth 02-20-2010 02:59 PM

PHP Widget in the CMS

zbosskiller 02-20-2010 02:59 PM

Create a new CMS PHP Widget mate.

zbosskiller 02-20-2010 03:05 PM

Great little widget Cody, thx.

Any chance you could make this so it works as a centre widget? i.e. above the Articles?

At the moment it is all right sided, which is correct for a sideblock.

If you have any time to do it I'd appreciate it.

Thx

Z

cory_booth 02-20-2010 03:11 PM

Quote:

Originally Posted by zbosskiller (Post 1987370)
Great little widget Cody, thx.

Any chance you could make this so it works as a centre widget? i.e. above the Articles?

At the moment it is all right sided, which is correct for a sideblock.

If you have any time to do it I'd appreciate it.

Thx

Z

Hmmm....
You mean just center all the text?

PHP Code:

$toutput .='<tr><td class="'.$class.'" align="left"> 

PHP Code:

$toutput .='<tr><td class="'.$class.'" align="center"> 


zbosskiller 02-20-2010 03:32 PM

It more so something like a block that has a header, in the header it shows

'Thread' | 'Posted By' | 'Views' | 'Last Post''

This is probably a lot of work but thought I would ask as its what I was used to with VB 3.8.4

cory_booth 02-20-2010 03:49 PM

Oh, gotcha - I know what you mean...

And believe it or not, I had something like that running but dumped it a long time ago.
(just experimenting)...

I'll see what I can scratch up...

zbosskiller 02-20-2010 03:57 PM

Thx, really appreciate it!

cory_booth 02-20-2010 05:50 PM

Hey I was thinking....
What if you put this in as a Widget...

https://vborg.vbsupport.ru/showthread.php?t=235841

You could turn off some of the areas and it would act as a threads module...

I don't have it installed, but try making a JS Enhanced Widget
Make a new template and insert:

{vb:raw vsatopstats}

Videx 02-21-2010 01:33 AM

Thanks. Installed.

For those that want to make it a little smaller (or larger), just edit the "LIMIT 0, 15" line. I dunno what the 0 means, but if I change 15 to 5, I only see 5 newest threads.

RedHacker 02-22-2010 07:37 AM

Cant show date....

cory_booth 02-22-2010 03:52 PM

You may wish to check here:
$recent_thread[lastpostdate] = vbdate('M jS', $recent_thread[lastpost], 1);

I suppose this hard-coded date format (M jS) might mess with other country formats.

sqzdog 02-22-2010 06:07 PM

Hey Cory- nice widget. I would like to use this but have it show latest posts instead of threads. Is there an easy way to do this?

klyde 02-22-2010 07:58 PM

Quote:

Originally Posted by RedHacker (Post 1988624)
Cant show date....

Replace:

Code:

$recent_thread[lastpostdate] = vbdate('M jS', $recent_thread[lastpost], 1);
by:

Code:

$recent_thread[lastpostdate] = vbdate($vbulletin->options['dateformat'] , $recent_thread[lastpost], 1);

cory_booth 02-22-2010 10:28 PM

Thanks Klyde...

Yeah I messed with things to get it as small as possible as a sidebar.

Videx 02-23-2010 12:41 AM

Yikes! A user just pointed out that ALL my threads are now being posted to the widget, including posts to our private Admin forums! I tried setting the forums in 'configure', but it seems to be ignoring the selection and is still posting Admin threads.

RedHacker 02-23-2010 05:00 AM

Thanks now it show fine....

redhawk89 02-26-2010 02:43 AM

Quote:

Originally Posted by sqzdog (Post 1988981)
Hey Cory- nice widget. I would like to use this but have it show latest posts instead of threads. Is there an easy way to do this?

x2 definitely this would be an epic widget

Trek 02-26-2010 03:27 AM

I like it. But it REALLY needs to check user perms and only show things they have access to. Also would need an exclude list in general for forums that you never want to appear.

Also would be good if it used the colors (optional of course) set for the usergroup.

Really nice though, no slight meant! I like the compactness of it and fleshed out a bit more, I'll be using it for sure.

cory_booth 02-26-2010 10:40 AM

Quote:

Originally Posted by Trek (Post 1991763)
I like it. But it REALLY needs to check user perms and only show things they have access to. Also would need an exclude list in general for forums that you never want to appear.

Also would be good if it used the colors (optional of course) set for the usergroup.

Really nice though, no slight meant! I like the compactness of it and fleshed out a bit more, I'll be using it for sure.

I totally agree with you and in fact felt a bit guilty when an above user pointed out the permission flaw... However, I am learning and was holding these little toys back but decided, what the heck - get 'em on here in the hopes someone with much greater skill than myself turns them into a more professional plugin...

x626xblack 02-26-2010 11:46 AM

Difference between this and the New Addition to the CMS for 4.0.2 "Recent Threads"?
I do believe it is built in now and there are no permission issues.

Trek 02-26-2010 05:52 PM

Quote:

Originally Posted by cory_booth (Post 1991901)
I totally agree with you and in fact felt a bit guilty when an above user pointed out the permission flaw... However, I am learning and was holding these little toys back but decided, what the heck - get 'em on here in the hopes someone with much greater skill than myself turns them into a more professional plugin...

No worries Cory, I really appreciate all of the things you have been releasing! =)

triff 02-27-2010 11:19 AM

What I would LOVE to see is a "recent post" widget with first the threadname (w/link to thread) and then some from the last post of that thread (w/link to the first UNREAD post). Like they had for old vBaCMPS.

SGL.

Inflikted 03-01-2010 06:51 PM

is there an easy way to block out private forums from this?

nevermind figured it out... for those others who wanted to know how

change
Code:

if (!in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) {
to the proper forumid's you would like to block
PHP Code:

ob_start(); 
global 
$vbulletin$db
//Begin Thread Counts 
$toutput=''
$recent_threads $vbulletin->db->query_read(
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle
FROM  " 
TABLE_PREFIX "thread AS thread 
LEFT JOIN  " 
TABLE_PREFIX "forum AS forum ON ( forum.forumid = thread.forumid ) 
WHERE NOT ISNULL(threadid) AND visible = '1' AND open!='10' 
ORDER BY lastpost DESC 
LIMIT 0, 10 
"
); 
$i 0
while (
$recent_thread $db->fetch_array($recent_threads)) 

$i++;
if (!
in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) { 
if (
$i 1) {$class='alt1';} else {$class='alt2';} 
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]); 
$recent_thread[lastpostdate] = vbdate('M jS'$recent_thread[lastpost], 1); 
$recent_thread[lastposttime] = vbdate($vbulletin->options['timeformat'], $recent_thread[lastpost]); 
$toutput .='<tr><td class="'.$class.'" align="left"><b><font color="#98B5E2" size="1" face="verdana,arial"><a href="showthread.php?t='.    $recent_thread[threadid].'">'.    $recent_thread[title].'</a></font></b><br/>'
$toutput .='<b><span style="color: #E1E1E2"><font size="1" face="verdana,arial">Last Post By: <a href="member.php?u='.$recent_thread[lastposterid].'">'.$recent_thread[lastposter].'</a></font><br/></span></b>'
$toutput .='<font size="1" face="verdana,arial">Forum: <a href="forumdisplay.php?f='.$recent_thread[forumid].'">'.$recent_thread[forumtitle].'</a> | Replies: '.$recent_thread[replycount].'</font><br/>'
$toutput .='<font size="1" face="verdana,arial">Posted: <strong>'.$recent_thread[lastpostdate].'</strong> at: <strong>'.    $recent_thread[lastposttime].'</strong></font><hr/></td></tr>'

}
//End Thread Counts 

//Sidebar - Begin Forum Threads 
$sb_threads 
<table class="tborder" cellpadding="'
.$stylevar[cellpadding].'" cellspacing="'.$stylevar[cellspacing].'" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"></td> </tr> </thead> <tbody> <div class="smallfont"> <tr> <td>
'
.$toutput.
</td> </tr> </div> </tbody> </table> 
'

//Sidebar - End Forum Threads 
echo $sb_threads
$db->free_result($recent_threads); 
$output=ob_get_contents(); 
ob_end_clean(); 


Videx 03-01-2010 07:48 PM

I figured it must be a simple matter of using an exclusion array, but I just didn't have the time to mess with it myself, so thanks for that. I'll try to test it later today.

A few suggestions to Cory before you include this: Maybe add a variable near the top so users don't have to go searching for the array; and specify what to put for ALL forums ('0' I guess), and an example of how to put numbers in the array (e.g. I don't think spaces will work).

Inflikted 03-03-2010 01:26 AM

yea its just a temporary fix. what i would really like to see is recent posts displayed based on user permission, so i don't have to filter boards. sorta like the 'whats new tab' i just don't no how to implement that.

Videx 03-03-2010 01:37 AM

Agreed. I suspect we'll see a lot of improvement in these things as more coders install and start working with vb4. For now, this works.

Inflikted 03-03-2010 02:31 PM

well i am willing to offer money to someone who can make this properly :) based on user permissions.

Videx 03-04-2010 03:35 AM

Well, this is odd. I can't see any of this widget at all in IE8! It looks good in Firefox and Chrome.

adreen 03-04-2010 05:56 AM

where is CMS in admincp?

Videx 03-04-2010 12:40 PM

Quote:

Originally Posted by adreen (Post 1996677)
where is CMS in admincp?

It should appear in the left menu. Mine is just below blogs and just above advertising.

alkrida 03-04-2010 01:51 PM

the arabic for it is :

PHP Code:

ob_start(); 
global 
$vbulletin$db
//Begin Thread Counts 
$toutput=''
$recent_threads $vbulletin->db->query_read(
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle 
FROM  " 
TABLE_PREFIX "thread AS thread 
LEFT JOIN  " 
TABLE_PREFIX "forum AS forum ON ( forum.forumid = thread.forumid ) 
WHERE NOT ISNULL(threadid) AND visible = '1' AND open!='10' 
ORDER BY lastpost DESC 
LIMIT 0, 15 
"
); 
$i 0
while (
$recent_thread $db->fetch_array($recent_threads)) 

$i++; 
if (
$i 1) {$class='alt1';} else {$class='alt2';} 
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]); 
$recent_thread[lastpostdate] = vbdate('M jS'$recent_thread[lastpost], 1); 
$recent_thread[lastposttime] = vbdate($vbulletin->options['timeformat'], $recent_thread[lastpost]); 
$toutput .='<tr><td class="'.$class.'" align="right"><font color="#CC0000" size="2" face="Tahoma"><a href="showthread.php?t='.    $recent_thread[threadid].'">'.    $recent_thread[title].'</a></font><br/>'
$toutput .='<font size="1" face="Tahoma">آخر مشاركة بواسطة: <a href="member.php?u='.$recent_thread[lastposterid].'">'.$recent_thread[lastposter].'</a></font><br/>'
$toutput .='<font size="1" face="Tahoma">قسم: <a href="forumdisplay.php?f='.$recent_thread[forumid].'">'.$recent_thread[forumtitle].'</a> | الردود: '.$recent_thread[replycount].'</font><br/>'
$toutput .='<font size="1" face="Tahoma">بتاريخ: <strong>'.$recent_thread[lastpostdate].'</strong> في: <strong>'.    $recent_thread[lastposttime].'</strong></font><hr/></td></tr>'

//End Thread Counts 

//Sidebar - Begin Forum Threads 
$sb_threads 
<table class="tborder" cellpadding="'
.$stylevar[cellpadding].'" cellspacing="'.$stylevar[cellspacing].'" border="0" width="100%" align="center"> <thead> <tr> <td class="tcat"></td> </tr> </thead> <tbody> <div class="smallfont"> <tr> <td> 
'
.$toutput.
</td> </tr> </div> </tbody> </table> 
'

//Sidebar - End Forum Threads 
echo $sb_threads
$db->free_result($recent_threads); 
$output=ob_get_contents(); 
ob_end_clean(); 


Videx 03-04-2010 03:16 PM

Quote:

Originally Posted by alkrida (Post 1996954)
the arabic for it is :

Be very careful. You have translated the broken one. This one will show ALL forums, regardless of a user's permissions. Better to use the second one which gives you an exclusion array.

Inflikted 03-04-2010 03:34 PM

im going to try my luck with vbadvanced for vbulletin 4.0. it seems there is alot more support and actual useful modules for it. buying the CMS package for vbulletin was a waste of money considering the lack of support for it.

RedHacker 03-06-2010 05:09 PM

Show the hidden threads... Can show the Unregisters\Registers usergroups....

Burnt 03-07-2010 05:20 PM

What if I wanted this to just take from one forum? What would I add/change to get that done?

Videx 03-07-2010 05:32 PM

It only has an exclusion array, so you would have to list all your other forums. Or just edit it and make the list inclusive. Take out the ! in "if (!in_array".

Fifth Dimension 03-07-2010 08:51 PM

This isn't working on my site. What I have done wrong? I copied and pasted the info into a new PHP widget, but all I see on the webpage is the text "03-07-2010" in the widget box.

Any ideas?

Videx 03-08-2010 12:33 AM

Quote:

Originally Posted by Fifth Dimension (Post 1999391)
This isn't working on my site. What I have done wrong? I copied and pasted the info into a new PHP widget, but all I see on the webpage is the text "03-07-2010" in the widget box.

Any ideas?

There's nothing in this code that should print a date without printing the hard coded word "Replies:". But who knows - you haven't even given us a link to look at. Can we assume you have no trouble putting up the default "Recent Posts" widget?


All times are GMT. The time now is 04:57 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.02765 seconds
  • Memory Usage 1,897KB
  • 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
  • (3)bbcode_code_printable
  • (5)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete