Forum Poll allows you to display polls from the forum module in your regular templates.
Example Usage
{exp:forumpoll topic_id="1"}
<h1>{poll_question}</h1>
Posted on {poll_date format="%Y/%m/%d"}
{if already_voted}
You have already voted in this poll
{/if}
<ul>
{poll_answers}
<li>{field} <label>{answer}</label></li>
{/poll_answers}
</ul>
{poll_submit}
{/exp:forumpoll}
Parameters
topic_id: The topic id of the poll. forum_id: If supplied without topic_id, the plugin will choose the newest poll in the forum. sticky: if set to ‘on’, will honour the sticky status of the topic. orderby: defaults to poll_date. sort: defaults to DESC. submit_text: Text to appear on the submit button, this now defaults to the cast_vote value in the forums ‘lang’ file.
note* If neither topic_id or forum_id are given, the plugin will choose the latest poll from the whole forum.
Variables
topic_id - The topic ID from which the poll came. title - Topic title. body - Body text from the originating topic. topic_url - The topics url. author_id - The author id of the poll. poll_question - The poll question. poll_date - The date the poll was posted. total_votes - The total number of votes in this poll. forum_id - The forum ID from where the poll came. poll_submit - The poll’s submit button.
Variable Pairs
poll_answers … /poll_answers: This is where you format your poll answers, the available variables inside this pair are below: field - The radio button. answer - The answer text. votes - Number of votes this answer has received. vote_share - Percentage of total votes that this answer has receieved.
Conditional Variables
if already_voted - will only show this content if the user has already voted in this poll. not_voted - The opposite of above. sticky - If the topic holding the poll is sticky. open - If the topic holding the poll is open. closed - If the topic holding the poll is closed.
You know what would be really great - if you could get a tag in there that would allow you to build a pulldown menu of all the polls in the forum (or with another parameter the last x polls)… The pulldown would be used to show results from that poll.
EDIT: looking at the database it actually is easy to do this. Nevermind the request above… Very cool plug-in and just when I was needing this functionality!! Thanks!
Hey - I just tested this out on my site. I got a Warning: Division by 0 error and {label} was echoed directly, unparsed.
Also - I was wondering if you would consider adding a return= parameter. I’d like to do something like this:
{if dem_topic_poll_id != ""}
{exp:forumpoll topic_id="{dem_topic_poll_id}" return="{comment_url_title_auto_path"}
<h1>{poll_question}</h1>
{if already_voted}
You have already voted in this poll
{/if}
<ul>
{poll_answers}
<li>{field} <label>{label}</label></li>
{/poll_answers}
</ul>
{poll_submit}
{/exp:forumpoll}
{/if}
to send it back to the comments page rather than to the forum topic. This would allow me to use the forum polls as a poll module, which’d rock.
Pretty cool idea, too, and finally getting time to play with it rocks. =)
Hey Lisa, I too spotted that error, it’s regarding a calculation done to work out the vote_share variable and there not being any votes for that answer. I’ve updated but haven’t gotten around to updating the file on the forums yet… sorry!
At the moment all of the database input is still handled by the forum module, this plugin just replicates the voting form so adding a ‘return’ parameter would either mean some kind of extension would need to be bundled along with the plugin, or the plugin itself mimicking the poll vote submission routine in viewthread().
I will look into it.
Edit: {label} is wrong, sorry my example was copied from a version from a galaxy far, far away, the variable you are looking for is {answer}
hello :D great plugin i must say :D
I am running my forums through standard templates, and I have this plugin on the side of the site along with some other things. When I click on vote, it uses the trigger word for the forums, instead of using my template. Is there a way to amend this?
Thanks
Patrick
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.