PDA

View Full Version : New poll feature: Multiple choice poll!


Chen
21 Oct 2001, 16:22
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
21 Oct 2001, 16:24
First screenshot - new poll screen.

Chen
21 Oct 2001, 16:24
Second screen shot - show thread screen.

Bane
21 Oct 2001, 16:28
Installed and working great on talkloud :) Great hack sir!

I may have mentioned this

Bane
21 Oct 2001, 16:39
Screen Shot on Talkloud!

Bane
21 Oct 2001, 16:51
After Vote :D

floleb7
21 Oct 2001, 16:56
but i see 2 votes but really it's one vote and 2 choices :D

Silviu
21 Oct 2001, 17:26
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
21 Oct 2001, 17:43
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
21 Oct 2001, 18:26
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
22 Oct 2001, 09:30
beautiful hack BUT, when I use it with vbportal, it doesnt allow multiple selections on the portal :(

can anyone help ?

cyrus
22 Oct 2001, 09:36
also, gives an error that I have not selected an option even when I know I have , so I cant vote full stop ! :(

Bane
22 Oct 2001, 10:45
Cyrus, you'll likely have to do some additional hacking if you want this to appear in the front page poll.

BluSmurf
22 Oct 2001, 11:17
great hack, installed with ease!

c0bra
22 Oct 2001, 13:56
Another great hack FireFly! Installation was a breeze, thanks very much... :D

GenSec
22 Oct 2001, 14:45
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
22 Oct 2001, 17:37
there is no file called vbpstuff.php in version 2.0.3 if vbportal !!!

:(

Chen
22 Oct 2001, 18:05
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
22 Oct 2001, 18:09
what about me FF ?? :( :(

RobAC
22 Oct 2001, 18:15
I get all kinds of undefined function errors such as cpheader and makelinkcode. :(

Chen
22 Oct 2001, 18:16
Cyrus, I don't use vbPortal.

RobAC, I suspect you didn't upload the installer to the admin folder. Is that correct?

RobAC
22 Oct 2001, 18:21
argh.....ok.....just slap me now! :mad: ;)

Chen
22 Oct 2001, 18:34
*looks around - BAM!*

RobAC
22 Oct 2001, 18:36
Works perfectly! Thanks Chen! :D

MarkG
23 Oct 2001, 08:11
it's wonderfull firefly!

thanks!!

http://apolyton.net/forums/showthread.php?threadid=30204

GenSec
23 Oct 2001, 08:39
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
23 Oct 2001, 08:54
Ive searched high and low, cant seem to find it anywhere myself :(

what should I Do ???

GenSec
23 Oct 2001, 09:09
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
23 Oct 2001, 09:25
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
23 Oct 2001, 10:31
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
23 Oct 2001, 10:36
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
23 Oct 2001, 11:02
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
23 Oct 2001, 12:13
right

so what do I do ???

what template do I edit and/or what php file do i edit ??

:confused:

Bane
23 Oct 2001, 12:17
P_polloptions or something to that effect

cyrus
23 Oct 2001, 12:22
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
23 Oct 2001, 12:23
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
23 Oct 2001, 12:25
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
23 Oct 2001, 12:30
i cant see any P_pollbits template listed here
BUT, I do have P_polltions as stated above

wht should I do ?

GenSec
23 Oct 2001, 12:34
Look for P_polloption

GenSec
23 Oct 2001, 12:36
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
23 Oct 2001, 12:39
how do I do that ?? :(

sorry, im totally confused here

GenSec
23 Oct 2001, 12:54
You need look for phpportal file which has string eval("\$P_pollbits .= \"".gettemplate("P_polloption")."\";");

cyrus
23 Oct 2001, 13:12
looked in P_polloptions, nothing of that nature in there !

GenSec
23 Oct 2001, 13:23
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
23 Oct 2001, 14:17
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
23 Oct 2001, 14:22
vbpstuff.php

cyrus
23 Oct 2001, 14:29
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
23 Oct 2001, 14:49
Let say It based on v2.01
In any case you have file which includes the same line as above
Just search

GenSec
23 Oct 2001, 14:50
First of all look for the file included in phpinclude template

cyrus
23 Oct 2001, 15:54
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
23 Oct 2001, 15:59
Look inside this file
any other include(vbp... .php)
or it can be just in index.php or vbphome.php

cyrus
23 Oct 2001, 16:06
there many other includes, but nothing with vbp starting the the brackets

shall I send u all the root of vbportal files ?? lol

GenSec
23 Oct 2001, 16:14
Ok. Do it

GenSec
23 Oct 2001, 16:19
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
23 Oct 2001, 17:30
ok, im lost again

this is hopeless :(

GenSec
24 Oct 2001, 06:30
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
26 Oct 2001, 19:28
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
26 Oct 2001, 19:42
You should have in php files the line

eval("\$P_pollbits .= \"".gettemplate("template_name ")."\";");

It gives you name of template to change.

Freddie Bingham
26 Oct 2001, 19:57
This will be part of the next version due out in a few days so I suggest waiting until then.

mister
02 Nov 2001, 20:51
Does having this hack installed cause problems when upgrading to 2.2.0 ?

Should I uninstall this hack, and then upgrade?
Or will I be fine?

Just wondering before I upgrade tonight...

Thanks

Chen
02 Nov 2001, 20:56
freddie (I think it was him?) added a check to the last upgrade script that checks if you have a field named multiple, and if you do, it skips that part of the upgrade.
I upgraded a test board using this hack to v2.2.0 with no problems. :)

wajones
03 Nov 2001, 05:41
Originally posted by cyrus
ok, im lost again

this is hopeless :(

The frontpage multi-choice poll is installed in the latest vbPortal beta pr7.1 for vBulletin 2.2 please inquire on phpPortals.

JTMON
07 Nov 2001, 03:04
The installer link up top need to be changed to this url to work.

Trillian
07 Nov 2001, 03:26
I haven't installed this hack yet, but I definitely will!

But I have a question: Can I limit the number of selections a user can make? Such as, there are 10 choices, but I only want the user to choose three: can I set a limit?

And thanks for your hard work :)

JTMON
07 Nov 2001, 03:28
Well I found out the hard way (via a MySQL error) that 2.2.0 has Multiple Choice Built in!!! I did not see a way to limit the amount of times they could vote. I voted for 3 outta 4 on my test.