View Full Version : [v2.0.3] New poll feature: Multiple choice poll!
Chen
Sun 21st Oct '01, 1:22pm
I know a lot people wanted and asked for this, so here it is, just for you! (and me :))
Pretty simple actually.
This adds an option to the new poll screen (screenshot 1 (http://www.vbulletin.com/forum/attachment.php?s=&postid=189814)), that lets you choose between a regular poll (like it is now), or a multiple choice poll.
If the latter is selected, instead of radio buttons there will be check boxes (screenshot 2 (http://www.vbulletin.com/forum/attachment.php?s=&postid=189815)).
I also must say that installation is rather simple.
All you need to do is edit 2 files, and 1 template.
The rest is done automatically.
This is the place to thank Bane (http://www.talkloud.net/) that generously let me use his great installer!
Without further ado, here's the installer:
Installer (http://www.vbulletin.com/forum/attachment.php?s=&postid=189878) - just upload to your admin folder and run in your browser.
(note: all installation is reversable. uninstallation can be done from the installer)
For a small add-on (not included in the installer), please see this (http://www.vbulletin.com/forum/showthread.php?s=&action=showpost&postid=190516) page.
Chen
Sun 21st Oct '01, 1:24pm
First screenshot - new poll screen.
Chen
Sun 21st Oct '01, 1:24pm
Second screen shot - show thread screen.
Bane
Sun 21st Oct '01, 1:28pm
Installed and working great on talkloud :) Great hack sir!
I may have mentioned this
Bane
Sun 21st Oct '01, 1:39pm
Screen Shot on Talkloud!
Bane
Sun 21st Oct '01, 1:51pm
After Vote :D
floleb7
Sun 21st Oct '01, 1:56pm
but i see 2 votes but really it's one vote and 2 choices :D
Silviu
Sun 21st Oct '01, 2:26pm
Hmm, i've downloaded the hack but there seems to be a small error. The field "multiple" from table "poll" is installed incorectly: actually is inserted as "mulitple" by your installer. So, when voting MySQL will generate an error: "multiple not in field list". :)
I've fixed it by setting the correct field name in MySQL administration panel.
BTW, great hack :D
drumsy
Sun 21st Oct '01, 2:43pm
I'm confused, does the installer do EVERYTHING for us, or is there something we're supposed to do manually. I installed it, but I get no choice to create the other poll.
Chen
Sun 21st Oct '01, 3:26pm
New installer (can't update first post).
Thanks. :)
drumsy, everything is on screen. What I can automatically is already done by the installer. You will need to do other changes to two files and another template.
Cyrus
Mon 22nd Oct '01, 6:30am
beautiful hack BUT, when I use it with vbportal, it doesnt allow multiple selections on the portal :(
can anyone help ?
Cyrus
Mon 22nd Oct '01, 6:36am
also, gives an error that I have not selected an option even when I know I have , so I cant vote full stop ! :(
Bane
Mon 22nd Oct '01, 7:45am
Cyrus, you'll likely have to do some additional hacking if you want this to appear in the front page poll.
BluSmurf
Mon 22nd Oct '01, 8:17am
great hack, installed with ease!
c0bra
Mon 22nd Oct '01, 10:56am
Another great hack FireFly! Installation was a breeze, thanks very much... :D
GenSec
Mon 22nd Oct '01, 11:45am
Originally posted by Cyrus
beautiful hack BUT, when I use it with vbportal, it doesnt allow multiple selections on the portal :(
can anyone help ?
Add temlate P_polloption_mult
<tr>
<td bgcolor="#DFDFDF" width="5%"><input type="checkbox" name="allvotes[$P_option[number]]" value="yes"></td>
<td bgcolor="#DFDFDF" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
Find in vbpstuff.php
eval("\$P_pollbits .= \"".gettemplate("P_polloption")."\";");
Replace with// Multi-Choice Hack
if ($P_pollinfo[multiple]!=0) {
eval("\$P_pollbits .= \"".gettemplate("P_polloption_mult")."\";");
} else {
eval("\$P_pollbits .= \"".gettemplate("P_polloption")."\";");
}
// Multi-Choice Hack
That's all.
P.S. Bravo FireFly!
Cyrus
Mon 22nd Oct '01, 2:37pm
there is no file called vbpstuff.php in version 2.0.3 if vbportal !!!
:(
Chen
Mon 22nd Oct '01, 3:05pm
Small addon re floleb7's first post.
This will display the number of voters with multi choice polls, instead of number of votes.
In showthread.php, find this:
$counter=0;
while ($counter++<$pollinfo[numberoptions]) {
$pollinfo[numbervotes]+=$splitvotes[$counter-1];
}
and add this right below it:
if ($pollinfo[multiple]!=0) {
$getvoters=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS voters FROM pollvote WHERE pollid='$pollid'");
$pollinfo[voters]=$getvoters[voters];
} else {
$pollinfo[voters]=$pollinfo[numbervotes];
}
Now in showthread_pollresults template, replace $pollinfo[numbervotes] votes with $pollinfo[voters] voters.
Easy wasn't it? :)
Cyrus
Mon 22nd Oct '01, 3:09pm
what about me FF ?? :( :(
RobAC
Mon 22nd Oct '01, 3:15pm
I get all kinds of undefined function errors such as cpheader and makelinkcode. :(
Chen
Mon 22nd Oct '01, 3:16pm
Cyrus, I don't use vbPortal.
RobAC, I suspect you didn't upload the installer to the admin folder. Is that correct?
RobAC
Mon 22nd Oct '01, 3:21pm
argh.....ok.....just slap me now! :mad: ;)
Chen
Mon 22nd Oct '01, 3:34pm
*looks around - BAM!*
RobAC
Mon 22nd Oct '01, 3:36pm
Works perfectly! Thanks Chen! :D
MarkG
Tue 23rd Oct '01, 5:11am
it's wonderfull firefly!
thanks!!
http://apolyton.net/forums/showthread.php?threadid=30204
GenSec
Tue 23rd Oct '01, 5:39am
Originally posted by Cyrus
there is no file called vbpstuff.php in version 2.0.3 if vbportal !!!
:( In your vbportal version should be something analogical. Look in your "phpinclude" template.
Cyrus
Tue 23rd Oct '01, 5:54am
Ive searched high and low, cant seem to find it anywhere myself :(
what should I Do ???
GenSec
Tue 23rd Oct '01, 6:09am
Originally posted by Cyrus
Ive searched high and low, cant seem to find it anywhere myself :(
what should I Do ???
[list=1]
To find temlate which produce poll table on your portal page. (Use admin CP -->options-->templates-->yes. Then view source of your page)
Find php file, which uses this template
[/list=1]
Cyrus
Tue 23rd Oct '01, 6:25am
i did that,
I then went and daw the source for the vbportal homepage, and it says p_home is the template.
so i searched for p_home in the vbp files and mailfile.php and header.php seem to mention it
what now ?
GenSec
Tue 23rd Oct '01, 7:31am
It can't be p_home. The temlate name should be like polloption... and looks like <tr>
<td bgcolor="#DFDFDF" width="5%"><input type="checkbox" name="allvotes[$P_option[number]]" value="yes"></td>
<td bgcolor="#DFDFDF" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
Cyrus
Tue 23rd Oct '01, 7:36am
that was what you told me to add in a new template as on the first post on page 2 of this thread!!!
:confused:
GenSec
Tue 23rd Oct '01, 8:02am
O, sorry. The original looks practically the same<tr>
<td bgcolor="{secondaltcolor}" width="5%"><input type="radio" name="optionnumber" value="$P_option[number]"></td>
<td bgcolor="{secondaltcolor}" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
Cyrus
Tue 23rd Oct '01, 9:13am
right
so what do I do ???
what template do I edit and/or what php file do i edit ??
:confused:
Bane
Tue 23rd Oct '01, 9:17am
P_polloptions or something to that effect
Cyrus
Tue 23rd Oct '01, 9:22am
this is what I got in p_polloptions template :-
<form action="$bburl/poll.php" method="get">
<input type="hidden" name="s" value="$session[dbsessionhash]">
<input type="hidden" name="action" value="pollvote">
<input type="hidden" name="pollid" value="$P_pollinfo[pollid]">
<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} width="{contenttablewidth}" align="center"><tr><td>
<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
<td bgcolor="{tableheadbgcolor}" align="center" colspan="4"><smallfont color="{tableheadtextcolor}"><b>$P_pollinfo[question]</b></smallfont></td>
</tr>
$P_pollbits
</table>
</td></tr></table>
<table cellpadding="2" cellspacing="0" border="0" width="100%" {tableinvisibleextra} align="center">
<tr>
<td style="font-size: 8pt"><smallfont><input type="submit" class="bginput" value="Vote!" style="font-size: 8pt">
<a href="$bburl/poll.php?s=$session[sessionhash]&action=showresults&pollid=$P_pollinfo[pollid]">View Results</a>
</smallfont></td></tr>
</table>
</form>
how should I edit that ?
GenSec
Tue 23rd Oct '01, 9:23am
You need create new template as shown above
and modify php file which use this template simular as made by FireFly for vB or in my first post.
GenSec
Tue 23rd Oct '01, 9:25am
You need P_pollbits temlate if you have.
In my case $P_pollbits based on P_polloption temlate. I guess you have P_polloption also.
Cyrus
Tue 23rd Oct '01, 9:30am
i cant see any P_pollbits template listed here
BUT, I do have P_polltions as stated above
wht should I do ?
GenSec
Tue 23rd Oct '01, 9:34am
Look for P_polloption
GenSec
Tue 23rd Oct '01, 9:36am
Originally posted by Cyrus
i cant see any P_pollbits template listed here
BUT, I do have P_polltions as stated above
wht should I do ?
Just what I say in first post.
Create new template and look for php file which create P_pollbits from P_polltions
Cyrus
Tue 23rd Oct '01, 9:39am
how do I do that ?? :(
sorry, im totally confused here
GenSec
Tue 23rd Oct '01, 9:54am
You need look for phpportal file which has string eval("\$P_pollbits .= \"".gettemplate("P_polloption")."\";");
Cyrus
Tue 23rd Oct '01, 10:12am
looked in P_polloptions, nothing of that nature in there !
GenSec
Tue 23rd Oct '01, 10:23am
Forget P_polloption.
Just create new template with name P_polloption_mult:
<tr>
<td bgcolor="{secondaltcolor}" width="5%"><input type="checkbox" name="allvotes[$P_option[number]]" value="yes"></td>
<td bgcolor="{secondaltcolor}" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
Then take on your local comp dir with your files.php for portal and look for one that has lineeval("\$P_pollbits .= \"".gettemplate("P_polloption")."\";"); .
It's not in templates.
Cyrus
Tue 23rd Oct '01, 11:17am
ah ok, so templates is out of the story, although I have added the one u said !
But as for the php file, I have searched ALL of the files in vbportal dir and NONE of them have that command in it anywhere. Am I mistaken ?? if so, where would it be ? I see Gen you have done multiple polls on your vbportal, which file did YOU change ?
thanks guys
GenSec
Tue 23rd Oct '01, 11:22am
vbpstuff.php
Cyrus
Tue 23rd Oct '01, 11:29am
lol
back to square one :-
I dont HAVE any file caleld vbpstuff.php anywhere on my server let alone on the vbportal directory :)
thats the problem
what version of vbportal are you using ? coul THAT be it ?
GenSec
Tue 23rd Oct '01, 11:49am
Let say It based on v2.01
In any case you have file which includes the same line as above
Just search
GenSec
Tue 23rd Oct '01, 11:50am
First of all look for the file included in phpinclude template
Cyrus
Tue 23rd Oct '01, 12:54pm
ok, I think the file I need to edit is
vbp_includes.php as it refers to that in the phpinclude template
Although I STILL dont see the eval.... command in there !
GenSec
Tue 23rd Oct '01, 12:59pm
Look inside this file
any other include(vbp... .php)
or it can be just in index.php or vbphome.php
Cyrus
Tue 23rd Oct '01, 1:06pm
there many other includes, but nothing with vbp starting the the brackets
shall I send u all the root of vbportal files ?? lol
GenSec
Tue 23rd Oct '01, 1:14pm
Ok. Do it
GenSec
Tue 23rd Oct '01, 1:19pm
By the end you can change the P_polloptions template and have the permanent multi poll form on the main page. It works in all cases.
Cyrus
Tue 23rd Oct '01, 2:30pm
ok, im lost again
this is hopeless :(
GenSec
Wed 24th Oct '01, 3:30am
Originally posted by Cyrus
ok, im lost again
this is hopeless :(
Ok, Cyrus. Just install FireFly hack, then open P_polloption and replace <tr>
<td bgcolor="{secondaltcolor}" width="5%"><input type="radio" name="optionnumber" value="$P_option[number]"></td>
<td bgcolor="{secondaltcolor}" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
with that<tr>
<td bgcolor="{secondaltcolor}" width="5%"><input type="checkbox" name="allvotes[$P_option[number]]" value="yes"></td>
<td bgcolor="{secondaltcolor}" colspan="3"><smallfont>$P_option[question]</smallfont></td>
</tr>
Try it.
Cyrus
Fri 26th Oct '01, 4:28pm
this is what i gt in P_polloption
<form action="$bburl/poll.php" method="get">
<input type="hidden" name="s" value="$session[dbsessionhash]">
<input type="hidden" name="action" value="pollvote">
<input type="hidden" name="pollid" value="$P_pollinfo[pollid]">
<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} width="{contenttablewidth}" align="center"><tr><td>
<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
<td bgcolor="{tableheadbgcolor}" align="center" colspan="4"><smallfont color="{tableheadtextcolor}"><b>$P_pollinfo[question]</b></smallfont></td>
</tr>
$P_pollbits
</table>
</td></tr></table>
<table cellpadding="2" cellspacing="0" border="0" width="100%" {tableinvisibleextra} align="center">
<tr>
<td style="font-size: 8pt"><smallfont><input type="submit" class="bginput" value="Vote!" style="font-size: 8pt">
<a href="$bburl/poll.php?s=$session[sessionhash]&action=showresults&pollid=$P_pollinfo[pollid]">View Results</a>
</smallfont></td></tr>
</table>
</form>
not anything you mentioned to change
thanks
GenSec
Fri 26th Oct '01, 4:42pm
You should have in php files the line
eval("\$P_pollbits .= \"".gettemplate("template_name ")."\";");
It gives you name of template to change.
Freddie Bingham
Fri 26th Oct '01, 4:57pm
This will be part of the next version due out in a few days so I suggest waiting until then.
vBulletin® v3.8.0 Beta 4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.