Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
$407 per month—let's make that $500!Learn more
With this snippet you're able to create a view for the poll questions and answers wich you have created in the manager but which are not published or active (or at least not latest) anymore. You can create two pairs of chunks; one pair of two chunks for the voting form and one pair of two chunks for the result view after you voted. Read down below how the templates are working and see what parameters could be set.
The PollsLatest snippet can be used simple putting this tag in your template or resource content
For parameter usage, please see the table below
|tplOuter||(Optional) An optional outer template could be set to surround the output|
|tpl||The question template, default used the pollsLatestResultOuter||pollsLatestResultOuter|
|tplAnswer||The answer template per question, default used the pollsLatestResultAnswer||pollsLatestResultAnswer|
|category||(Optional) Will select the latest poll from the given category (id). Could be multiple by given a comma seperated list of category ids|
|unpubOnly||(Optional) Will show unpublished polls only||0|
|showHidden||(Optional) Will show hidden polls too||0|
|sortby||(Optional) To influence the normal order, order could be any field in list||id|
|sortdir||(Optional) To influence the normal order direction||DESC|
|limit||(Optional) To limit the results.Compatibility for getPage (paging)|
|offset||(Optional) To set the offset, to start selecting from.Compatibility for getPage (paging)||0|
|totalVar||(Optional) Set the name of the total count of questions. Compatibility for getPage (paging)||total|
Note: the sort options are normally not need to change!
|resultResource||(Optional) When set to a resource id, this resource will be used to show the poll results|
|resultLinkVar||(Optional) When using resultResource, this is the parametername the snippet is looking for||poll|
Within the templates for this snippet you can use the following placeholders to generate your view.
||The question id of the current poll view|
||The question text|
||The publishdate of the question|
||The unpublishdate of the question|
||The total number of votes on this poll|
||The name of the poll category (only availbale when using the category property)|
||The URL of the results view (only available when using the resultResource property)|
||Contains the output of the answers generated for this poll question|
||The id of the answer record|
||The loop number of the answers list (start: 1)|
||The answer text|
||The number of votes for this answer|
||The percentage of the number of votes for this answer|
Note: for the results view of this snippet, the same placeholders as above are available, including this extra one.
||The datetime of the vote of the current visitor (based on IP address)|
The default call of this snippet returns a basic view of the poll-vote and poll-results. You can change above parameters to create your own (also possible by propertysets).
[[!PollsLatest? &tplVote=`myVoteOuter` &tplVoteAnswer=`myVoteAnswer`]]
To select the latest poll from a category, specify the category parameter
Selecting latest questions from multiple given id's