We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Forumpoll

Development and Programming

Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

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.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

Oh… wow. You, sir, are wonderful. =)

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

Noted a bug that redirects to the wrong place on voting if using any method of removing ‘index.php’ from your site url’s. I will update this, soon :D

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

Ver 1.1 - Fixed path problem - Added more parameters - Added more conditionals

       
Brian M.'s avatar
Brian M.
529 posts
18 years ago
Brian M.'s avatar Brian M.

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!

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

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. =)

       
Daniel Walton's avatar
Daniel Walton
553 posts
about 18 years ago
Daniel Walton's avatar Daniel Walton

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}

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 18 years ago
Lisa Wess's avatar Lisa Wess

Aha that explains things. I’m not great with forms but is there some way I could pass a hidden value to the submit button to return me to the right please, perhaps? Hrm. I hate forms, really. =)

       
Daniel Walton's avatar
Daniel Walton
553 posts
about 18 years ago
Daniel Walton's avatar Daniel Walton

At this time, not that im aware of, i did look through the vote submission process to see if there was a way i could force any kind of redirect through submitted fields but it didn’t look promising.

       
Daniel Walton's avatar
Daniel Walton
553 posts
about 18 years ago
Daniel Walton's avatar Daniel Walton

Oh, and i’ve just fixed that division by zero error, new attachment at top of thread 😊

       
AussieFreelancer's avatar
AussieFreelancer
72 posts
17 years ago
AussieFreelancer's avatar AussieFreelancer

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

       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

Hmm, added forumpoll re-haul the todo list Patrick :D

Thanks for spotting this.

       
AussieFreelancer's avatar
AussieFreelancer
72 posts
17 years ago
AussieFreelancer's avatar AussieFreelancer

no worries :D

       
mattbrighton's avatar
mattbrighton
50 posts
17 years ago
mattbrighton's avatar mattbrighton

only just spotted this plugin. perfect. will check out.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.