Important update:EasyPoll can now be found in the MODx Resource Repository.
The following documentation is outdated. Please consider reading the Documentation that comes with the EasyPoll Download or
read it online.
Please post feedback, error-reports or suggestions in the support thread:
http://modxcms.com/forums/index.php/topic,22981.0.html
Hello all
Some of you might have seen
my thread in the Module, Plugin & Snippet Forum. I started to develop a new Poll Module for MODx. First based on the Poll Module by garryn, this has turned into a full rewrite.
Now the first release is up for you to grab and test. It would be awesome if some of you would take the time to install and test! Everything worked just fine here, but you never know how it runs on another box.
Attention: This modules requires at least PHP 5 and MySQL 4.1. Do not attempt to run it when you do not meet these requirementsPlease note that there are currently only lang files for German and English (these are most likely not perfect, since English is not my native language).New: Dutch translation by peterruiter, thanks a lot
Installation instructions:- Grab EasyPoll 0.3. Unzip to a directory of your choice
- You should see two folders, modules and snippets (plus maybe some mac garbage, sorry for that
) - Copy the EasyPoll Folder from modules to your modx modules directory. Copy the EasyPoll Folder from snippets to your modx snippets directory
- Create a new Snippet called "EasyPoll" and copy/paste the contents from snippet.php (to be found in the snippets/EasyPoll folder) into it.
- Create a new Module called "EasyPoll" and copy/paste the contents from module.php (modules/EasyPoll) into it (don't forget to remove the <?php ?> Tags)
- Still in "Manage Modules", click on the icon on the left of the newly created "EasyPoll" Module and select "Run module"
You should now see something like this:
- Click the install button to create the needed tables. If this completes successfully, you might want to delete the setup.sql file (it was used to create the db tables)
- You should now see several Tabs. First go to "Languages"
- Create the Languages you would like to create Polls for. Even on a 1 language site, you have to at least create one language.
Here is how it looks with 4 languages:
- You can now move on to create your polls. Switch to the "Polls" tab and create a new Poll by filling the fields
- Start-date and End-date are optional. You can specify a start and/or end date for your poll here. If you don't set the Start-Date, it will be set to the current date. This allows you to change your polls appearance on your site (by changing the start-date).
- The "Active" checkbox determines weather or not this Poll is currently active. Poll that are NOT active won't be shown on your Site!
- After creating a poll, you may click the "Edit choices" Button to add/edit or remove Poll choices
Here are two screenshots of the Poll editing process:

Continue to create more polls and choices...
Snippet usageBasically a call like [!EasyPoll!] will work. This won't fit your needs in most of the cases though. You need some parameters:
&pollidPoll ID to be used. If not set, the snippet will choose the most recent Poll (must be active and fully translated)! You are encouraged to omit this parameter, since it opens the possibility for you to administrate polls in the manager and have them automatically updated on your site.
(defaults to false)&langthe language to use for snippet translations
(defaults to 'en').
Currently available Languages: de, en, nl&easylangthe language for poll questions and answers (as set up in manager).
defaults to the &lang param&onevoteBoolean indicating if a user is allowed to vote just once
(defaults to false)&useipBoolean indicating if we should log the users ip to allow just one vote
(defaults to false)&ovtimeCookie expiration time
(defaults to one week)&cssAdditional stylesheet to load
(defaults to none/false)&accuracyaccuracy of percentage rounding. this specifies the number of digits after the decimal point
(defaults to 1)&tplVoteOuterOuter container template for votes.
Default:<div class="pollvotes">
<h3>[+question+]</h3>
<ul>[+choices+]</ul>
[+submit+] [+results+]
</div>
&tplVoteTemplate for a single voting option
Default:<li>[+select+] [+answer+]</li>
&tplResultOuterOuter container template for results
Default:<div class="pollresults">
<h3>[+question+]</h3>
<ul>[+choices+]</ul>
<p>[+totaltext+]: [+totalvotes+]</p>
</div>
&tplResultTemplate for a single result
Default:<li>
<strong>[+answer+]</strong> ([+votes+] / [+percent+]%)
<div class="easypoll_bar">
<div class="easypoll_inner" style="width:[+percent_int+]%"></div>
</div>
</li>
&tplErrorTemplate that is used to display a error message
Default:<div class="easypoll_error">[+message+]</div>
&identifierthe element identifier that is used for the js commands. change this to something unique every time
if you plan to use multiple polls on one page. Eg. easypoll1, easypoll2, etc.
(defaults to "easypoll")&nojsBoolean. Suppress inclusion of mootools. Use this if mootools is already included
(defaults to false)&customjsinclude a custom javascript code (eg. your custom callback function definiton). This can be a path to a JS File or a script wrapped in <script> tags. You can specify a chunk as well, use @CHUNK:<chunkname> for this purpose.
(defaults to none)&jscallbackjscallback can be any javascript function name. It will be called first when the ajax loading starts and a second time when loading is complete.
You'll get 2 parameters for that function. The first one is the response. The response is FALSE when loading has just started and contains the loaded HTML if loading is done.
The second parameter is the id of the poll element. This is the same as specified in &identifier and will help you to route the responses to the correct poll if you're using multiple polls on one page.
(defaults to "EasyPoll_DefaultCallback" which will be written into the HTML Code by the snippet)&showexceptionIf set to true, even "invisible" exceptions like the one occuring if no poll was found will be shown!
This is useful for testing, should not be used in production environment though.
(defaults to false)Template PlaceholdersPlease note that the tplVoteOuter template is always wrapped in a div with id=
<&identifier> and class="easypoll"! Since the results are loaded via AJAX and injected
into this element (unless you specify your own callback function), this element should only serve as a container and not used for general styling (because it won't persist if you call the snippet the "non-Ajax" way).
The tplVoteOuter will also be wrapped in a form element.
This is done to ensure functionality of the poll snippet (form and ajax).
tplVoteOuter[+question+] = the title/question of the poll
[+choices+] = the vote options/choices
[+submit+] = the submit button will be injected there. don't forget this or the user won't be able to vote
[+results+] = button to show results. not mandatory, since results will be shown upon voting
tplResultOuter[+question+] = the title/question of the poll
[+totalvotes+] = the total amount of votes that were cast for this poll
[+totaltext+] = the text.. eg. "Total votes" for english
[+choices+] = the choice results
tplVote[+select+] = the radio button. don't forget this or the user won't be able to vote at all
[+answer+] = the answer. don't forget this. please
tplResult[+answer+] = the answer
[+percent+] = the percent value of this result (without %, accuracy according to &accuracy param)
[+percent_int+] = integer value of the percentage. can be used for css styling. eg. width:[+percent_int+]%;
[+votes+] = the number of votes that went in for this question/option
tplError[+message+] = The error message
Usage examplesThis is how you should probably start. Specify a poll id (as seen in the EasyPoll Module) and set the showexception flag to 1. This allows you to test the poll output and see exceptions if they occur. Do not use this on a live environment.
[!EasyPoll? &pollid=`1` &showexception=`1`!]
This is a call, how it could be used on the MODx Demo Site. User may only vote once (we're using a cookie and log the ip to assure this). We disable the inclusion of mootools (since it is included by another script) and use our own stylesheet (we're using the simple stylesheet i provided with the snippet)
[!EasyPoll? &onevote=`1` &useip=`1` &nojs=`1` &css=`assets/snippets/EasyPoll/poll.css`!]
The following screenshots show a simple poll integrated into the MODx Demo Site:Voting:

Results:

So far so good.
Any input is highly appreciated! It would be awesome if i could find some testers on this boardThanks for reading
-- banal
Edit (2008-02-05)
There is currently a Bug when using the "MODxGreen" theme in the manager. Some Buttons have a invisible label. Please use either MODx or MODxLight theme until this is fixed.
Edit (2008-02-05)
Fixed the above Bug. The Manager should now be usable with all 3 MODx Manager Themes. I have a small suggestions to the MODx developers here: would it be possible to have a "common" Icon set that is not bound to themes? It would be useful for Module developers so they don't have to ship their own icons and are not bound to a theme? Just a sidenote though, maybe somebody picks this up.
I changed some small things when it comes to chunk templates and styleshees. The way i built v. 0.1 wasn't very practical for styling when using multiple polls on the same page (although this might happen rarely). The poll.css file and the Templates reflect that change, thus we're at Version 0.1.1
Edit (2008-02-06)
Found a small Bug when it comes to sorting and deletion of Choices. Just a nuisance.. but will be fixed in the next release
Edit (2008-02-11)
Version 0.2 released!
This document has been updated to reflect the changes in Version 0.2
DB Structure wasn't changed, so if you're already running a older version, a simple File-replacement and update of the Module and the Snippet will do.
Edit (2008-02-15)
Version 0.2.1 released.
A dutch translation is now available, thanks to peterruiter.
Output of a poll archive is now implemented in the snippet code. Documentation currently only in the snippet, will soon post a updated documentation.