PDA

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


Admin
10-20-2001, 10:00 PM
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.

Admin
10-21-2001, 03:24 PM
First screenshot - new poll screen.

Admin
10-21-2001, 03:24 PM
Second screen shot - show thread screen.

Bane
10-21-2001, 03:28 PM
Installed and working great on talkloud :) Great hack sir!

I may have mentioned this

Bane
10-21-2001, 03:39 PM
Screen Shot on Talkloud!

Bane
10-21-2001, 03:51 PM
After Vote :D

floleb7
10-21-2001, 03:56 PM
but i see 2 votes but really it's one vote and 2 choices :D

Silviu
10-21-2001, 04:26 PM
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
10-21-2001, 04:43 PM
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.

Admin
10-21-2001, 05:26 PM
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
10-22-2001, 08:30 AM
beautiful hack BUT, when I use it with vbportal, it doesnt allow multiple selections on the portal :(

can anyone help ?

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

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

BluSmurf
10-22-2001, 10:17 AM
great hack, installed with ease!

c0bra
10-22-2001, 12:56 PM
Another great hack FireFly! Installation was a breeze, thanks very much... :D

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

:(

Admin
10-22-2001, 05:05 PM
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
10-22-2001, 05:09 PM
what about me FF ?? :( :(

RobAC
10-22-2001, 05:15 PM
I get all kinds of undefined function errors such as cpheader and makelinkcode. :(

Admin
10-22-2001, 05:16 PM
Cyrus, I don't use vbPortal.

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

RobAC
10-22-2001, 05:21 PM
argh.....ok.....just slap me now! :mad: ;)

Admin
10-22-2001, 05:34 PM
*looks around - BAM!*

RobAC
10-22-2001, 05:36 PM
Works perfectly! Thanks Chen! :D

MarkG
10-23-2001, 07:11 AM
it's wonderfull firefly!

thanks!!

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

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

what should I Do ???

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

so what do I do ???

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

:confused:

Bane
10-23-2001, 11:17 AM
P_polloptions or something to that effect

cyrus
10-23-2001, 11:22 AM
this is what I got in p_polloptions template :-

[QUOTE]<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>

GenSec
10-23-2001, 11:23 AM
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
10-23-2001, 11:25 AM
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
10-23-2001, 11:30 AM
i cant see any P_pollbits template listed here
BUT, I do have P_polltions as stated above

wht should I do ?

GenSec
10-23-2001, 11:34 AM
Look for P_polloption

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

sorry, im totally confused here

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

cyrus
10-23-2001, 12:12 PM
looked in P_polloptions, nothing of that nature in there !

GenSec
10-23-2001, 12:23 PM
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
10-23-2001, 01:17 PM
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
10-23-2001, 01:22 PM
vbpstuff.php

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

GenSec
10-23-2001, 01:50 PM
First of all look for the file included in phpinclude template

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

cyrus
10-23-2001, 03:06 PM
there many other includes, but nothing with vbp starting the the brackets

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

GenSec
10-23-2001, 03:14 PM
Ok. Do it

GenSec
10-23-2001, 03:19 PM
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
10-23-2001, 04:30 PM
ok, im lost again

this is hopeless :(

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

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

It gives you name of template to change.

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

mister
11-02-2001, 07:51 PM
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

Admin
11-02-2001, 07:56 PM
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
11-03-2001, 04:41 AM
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
11-07-2001, 02:04 AM
The installer link up top need to be changed to this url to work.

Trillian
11-07-2001, 02:26 AM
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
11-07-2001, 02:28 AM
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.