View Full Version : Closed Poll thread title
noppid
05-04-2003, 10:00 PM
A user requested (https://vborg.vbsupport.ru/showthread.php?s=&threadid=51697) that if a poll is closed the thread be preceeded by Closed Poll: instead of just Poll:.
Here's a few lines of code that did it for us. (see attachment )
All you have to do is insert a few lines of code to forumdisplay.php.
Good luck, hope it helps.
History:
1.4
Added closed poll functionality to search.php in showresult function.
1.3
Added field to poll table lookup.
Added condition to show poll closed when timeout has occured.
Elimiated HTML tags for bold since the default vB prefixes are not bold.
1.2
Removed HTML tag for font color.
1.1
Added condition to show poll closed if thread or poll is closed.
1.0
Initial release.
noppid
05-05-2003, 01:49 PM
Here's a preview.
Dean C
05-05-2003, 03:04 PM
Good idea - i'm going to use this :)
- miSt
all-the-vb
05-05-2003, 08:24 PM
Nice :D
colicab-d
05-05-2003, 10:42 PM
good idea
WEForums
05-05-2003, 11:15 PM
...doesn't seem to do anything....strange.....
EDIT: Nevermind. It doesn't work when locking a poll (locking the entire thread, that is).
Boofo
05-06-2003, 03:47 AM
Does this add a query for every poll in the forum? Or just the closed ones?
noppid
05-06-2003, 04:21 AM
Today at 12:47 AM Boofo said this in Post #9 (https://vborg.vbsupport.ru/showthread.php?postid=392057#post392057)
Does this add a query for every poll in the forum? Or just the closed ones?
A query occurs for each thread with a poll attached that is going to be displayed to see if it is open or closed.
The guys that wrote vB are sharp, we're not dealing with "ALL" the posts in the forum when we do a display. We get the number of threads that is set in the admin panel displayed. So, if I'm reading this code correctly, a forum display of 15 threads occuring would yield - worst case senario if all 15 threads have polls - 15 additional queries per forumdisplay. This is usually about 3 or 4 from what I've seen. Boards with more polls may want to be aware of the over head though.
Thanks. That help?
Regards
noppid
05-06-2003, 04:27 AM
Yesterday at 08:15 PM WEForums said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=391957#post391957)
...doesn't seem to do anything....strange.....
EDIT: Nevermind. It doesn't work when locking a poll (locking the entire thread, that is).
We do not have this issue. When we lock a thread with a closed poll, the closed poll tag still shows. Maybe you can show the block of code you edited so we can debug.
Regards
Boofo
05-06-2003, 04:38 AM
Today at 12:21 AM noppid said this in Post #10 (https://vborg.vbsupport.ru/showthread.php?postid=392065#post392065)
A query occurs for each thread with a poll attached that is going to be displayed to see if it is open or closed.
The guys that wrote vB are sharp, we're not dealing with "ALL" the posts in the forum when we do a display. We get the number of threads that is set in the admin panel displayed. So, if I'm reading this code correctly, a forum display of 15 threads occuring would yield - worst case senario if all 15 threads have polls - 15 additional queries per forumdisplay. This is usually about 3 or 4 from what I've seen. Boards with more polls may want to be aware of the over head though.
Thanks. That help?
Regards
I have a forum that is just for polls. So all of the threads would have polls. Ouch. ;)
noppid
05-06-2003, 06:53 PM
Today at 01:38 AM Boofo said this in Post #12 (https://vborg.vbsupport.ru/showthread.php?postid=392069#post392069)
I have a forum that is just for polls. So all of the threads would have polls. Ouch. ;)
When ya think about it in the terms of the amount of queries some pages have, IMHO 15 indexed queries is not really an ouch. I'd think most of the lookups would actually be cached after the first time it ran as well. If you have a way of benchmarking then perhaps a true measure of the overhead could be taken. I'm curious to know how effiecent a single field indexed lookup is or isn't.
Thanks for the reply.
Regards
Boofo
05-06-2003, 06:59 PM
Your idea here might be a good thing to add to my Polls Start Date and Time hack. I could have it automatically do a Poll Closed when the poll is over. Could I save some queries doing it that way?
noppid
05-06-2003, 07:03 PM
Unfortunatly I'm not familiar with the code you refer to, but I'd be glad to look at it. Perhaps we can create a tighter piece of code for the Poll closed hack.
Got a link? Can ya post the code snippet for the hack and where it goes in what form?
Thanks
Boofo
05-06-2003, 07:32 PM
It's in my signature in this message. ;)
WEForums
05-06-2003, 09:30 PM
Today at 06:27 AM noppid said this in Post #11 (https://vborg.vbsupport.ru/showthread.php?postid=392066#post392066)
We do not have this issue. When we lock a thread with a closed poll, the closed poll tag still shows. Maybe you can show the block of code you edited so we can debug.
Regards I followed the instructions. I created a new thread, locked the entire thread, and get "Poll:" still.
Anyone else having this problem?
Locking the poll works, but not the thread.
Boofo
05-06-2003, 09:46 PM
Does it say Closed Poll: before you close the thread?
noppid
05-06-2003, 09:50 PM
If the poll is closed yes, they are seperate functions.
Boofo
05-06-2003, 10:06 PM
Here is the link to my poll hack. Let me know if you think we can combine the two. ;)
https://vborg.vbsupport.ru/attachment.php?s=&postid=372862
Attrox
05-06-2003, 11:16 PM
Cool addition, small, yet very useful. *clicks install*
Nice idea. :)
WEForums
05-06-2003, 11:35 PM
Yesterday at 11:46 PM Boofo said this in Post #18 (https://vborg.vbsupport.ru/showthread.php?postid=392491#post392491)
Does it say Closed Poll: before you close the thread? It only says "Closed Poll:" when the poll is closed via the moderator edit button. When closing the entire thread all that appears is "Poll:" like normal.
noppid
05-07-2003, 03:09 AM
Yesterday at 08:35 PM WEForums said this in Post #22 (https://vborg.vbsupport.ru/showthread.php?postid=392519#post392519)
It only says "Closed Poll:" when the poll is closed via the moderator edit button. When closing the entire thread all that appears is "Poll:" like normal.
A new version 1.1 is posted with a new condition to show the poll closed if the thread is closed.
Thanks for the feedback.
Regards
noppid
05-07-2003, 01:09 PM
Yesterday at 07:06 PM Boofo said this in Post #20 (https://vborg.vbsupport.ru/showthread.php?postid=392494#post392494)
Here is the link to my poll hack. Let me know if you think we can combine the two. ;)
https://vborg.vbsupport.ru/attachment.php?s=&postid=372862
I was toast last night and really couldn't see well enough to read your code. I'll look closer at it today.
Boofo
05-07-2003, 01:11 PM
Today at 09:09 AM noppid said this in Post #24 (https://vborg.vbsupport.ru/showthread.php?postid=392692#post392692)
I was toast last night and really couldn't see well enough to read your code. I'll look closer at it today.
No problem. Just when you get some time. ;)
noppid
05-07-2003, 02:37 PM
OK to this line you need to add the active column name.
FROM:
$polldatetime = $DB_site->query_first("SELECT dateline, timeout from poll where pollid = $thread[pollid];");
TO:
$polldatetime = $DB_site->query_first("SELECT dateline, timeout,active from poll where pollid = $thread[pollid];");
That will enable you to do this conditional check and output or similar...
if($polldatetime['active']==0 || $thread[open]==0) {
$thread[typeprefix]="<b><font color=#567688>Closed Poll:</b></font> ";
}
else
$thread[typeprefix]=$pollthreadprefix;
Hope that helps.
Regards
Boofo
05-07-2003, 04:40 PM
I almost have it. I am working on a small problem. How do I go about get the total votes on a poll. I can pull them out but they look like this:
3|||2|||3|||2|||4|||
Like that. How do I get them into a total?
noppid
05-07-2003, 05:13 PM
You can use a foreach loop with an explode statement .
$totalvotes=0;
$myvotes = explode("|||",$votesstring);
foreach($myvotes as $v ) {
$totalvotes = $totalvotes + $v;
}
That should work though I didn't test it.
EDIT:
repaired code
Boofo
05-07-2003, 05:24 PM
Just tried it. It gives me 0 as the total votes and there are 10. ;)
noppid
05-07-2003, 05:30 PM
Does $votesstring exist for you? If not did you substitute you var name that contains the ||| delimited string?
Boofo
05-07-2003, 05:33 PM
Here's my query:
$polldatetime = $DB_site->query_first("SELECT dateline,timeout,active,votes,voters from poll where pollid = $thread[pollid];");
noppid
05-07-2003, 05:40 PM
Change $votesstring to $polldatetime['votes'] as below...
$totalvotes=0;
$myvotes = explode("|||",$polldatetime['votes']);
foreach($myvotes as $v ) {
$totalvotes = $totalvotes + $v;
}
EDIT:
repaired code
Boofo
05-07-2003, 05:43 PM
I tried that just before you wrote this and now the count reads 1 vote. ;)
noppid
05-07-2003, 05:50 PM
try
$totalvotes = $totalvotes + intval($v);
}
I don't have your code in place to test it for ya.
EDIT:
repaired code
Boofo
05-07-2003, 05:56 PM
Still only shows 1. ;)
noppid
05-07-2003, 06:00 PM
Dammit man, it's my fault!!! I left the $ off of the var...
Here ya go.
$totalvotes=0;
$myvotes = explode("|||",$polldatetime['votes']);
foreach($myvotes as $v ) {
$totalvotes = $totalvotes + $v;
}
Boofo
05-07-2003, 06:03 PM
I put the $ on the variable when I tried it. It gave me an error until I did. ;)
noppid
05-07-2003, 06:05 PM
Today at 03:03 PM Boofo said this in Post #37 (https://vborg.vbsupport.ru/showthread.php?postid=392824#post392824)
I put the $ on the variable when I tried it. It gave me an error until I did. ;)
I left the $ off of 2 vars
$polldatetime['votes']
and
$totalvotes
Boofo
05-07-2003, 06:07 PM
Oh, ok. Now it works. You meant the $totalvotes variable. You also left it off of the polldatetime['votes'] the first time. LOL Great! Now it work fantastic. Do you want to look over everything now that I have it working to give me your honest opinion? I can pm it to you. ;)
noppid
05-07-2003, 06:10 PM
If it's based on your existing code, from what I saw you should be fine.
I guess it's time to post an update to your hack.
I'd be glad to review it.
Boofo
05-07-2003, 06:12 PM
It's on it's way. Thank you for all of the help, ;)
Cyricx
05-12-2003, 02:55 AM
O rock! Thank you so very much I cannot wait to try this out :)
Your a god!
-Sidekick-
05-20-2003, 06:58 AM
I have a board with multiple styles. I was wondering if there is a way to make this hack more user friendly to boards with multiple styles.
Cause I see now that you have to define the font color for the term "Closed Poll."
Well the font color wouldn't work for all styles on my board. -.-
noppid
05-20-2003, 06:04 PM
I wanted specific highlighting. For normal text just change...
This:
$thread[typeprefix]="<b><font color=#567688>Closed Poll:</b></font> ";
To this:
$thread[typeprefix]="<b>Closed Poll:</b>";
That should do it. If I'm not mistaken just text passed in the default var. I left the bold tag. If there is any more html, I'm sure someone will point it out.
Cyricx
05-20-2003, 09:06 PM
Okay, finally got the time to get this installed, and very nice :)
Question, when you set a poll to be open for x number of days, when that time limit is up the poll won't let you vote anymore. However, this hack only picks it up as a "closed poll" if you edit the poll and manually close it that way.
Is there a way for it to recognize when a poll is closed due to "Time Out:"?
Very nice hack either way bud! Thanks!
noppid
05-21-2003, 12:17 AM
I'll check the DB fields and see if that is an option.
If there is an indicator other then open or closed it can prolly be done.
Boofo
05-21-2003, 01:01 AM
noppid, you should be able to use this to see if the poll is open, shouldn't you?
$pollinfo[active]
noppid
05-21-2003, 03:05 PM
That var does not seem available. It looks like we'll just be doing another test on the poll field named timeout.
Look for an update today.
noppid
05-21-2003, 03:51 PM
Updated code to show the thread closed if the poll timeout field is set is posted.
Regards
Orlando_Bloom
05-22-2003, 06:53 PM
Very Nice!
THX
Orlando
-Sidekick-
06-09-2003, 06:16 PM
Can this be modified so when searching for the new posts, closed polls show the same instead of just Poll: ?
noppid
07-15-2003, 06:17 PM
06-09-03 at 03:16 PM -Sidekick- said this in Post #51 (https://vborg.vbsupport.ru/showthread.php?postid=406662#post406662)
Can this be modified so when searching for the new posts, closed polls show the same instead of just Poll: ?
I'll look into it.
noppid
07-15-2003, 06:42 PM
06-09-03 at 03:16 PM -Sidekick- said this in Post #51 (https://vborg.vbsupport.ru/showthread.php?postid=406662#post406662)
Can this be modified so when searching for the new posts, closed polls show the same instead of just Poll: ?
An update has been posted.
Thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.