Poll Position: Template Tags


The tags below will help you build a poll or quiz submission or results template. Fully functional examples of these templates are found in the plugin archive at plugins/PollPosition/default_templates.

All of Poll Position’s tags support static publishing only; dynamic publishing is not supported. Poll tags output poll and quiz field values and results; “poll” and “quiz” can be used interchangeably in the descriptions of the tags.

CompletePoll

This function tag outputs a form with all the necessary HTML for a poll. If Javascript elements have been properly included on the page, this single tag generates a fully-functional poll. The most recently-created poll with voting open will be published.

Attributes

  • poll_id, as in <mt:CompletePoll poll_id="123">. Returns complete HTML for the specified poll. Any poll can be specified, including those with voting closed, or that are unpublished. A poll’s ID can be found on the Edit Poll page.

Polls

A block tag to enter the polls context.

Attributes

  • poll_id, as above.
  • type, specifies the type of object to return. Leave this value undefined to return both polls and quizzes. Alternatively, specify poll or quiz to filter the result.
  • lastn, just as it’s used within the rest of MT, to display the last “N” polls.
  • offset, just as it’s used within the rest of MT, in conjuction with lastn.

PollID

Returns the ID of the current poll. This is a particularly important value because it’s integral to creating a unique form. Must be used in the Polls context.

PollTitle

Returns the title you’ve entered for your poll. Must be used in the Polls context.

PollQuestion

Returns the question text for your poll. Must be used in the Polls context.

PollTotalVotes

Returns the total number of votes received for a poll, aggregating all response counts. Must be used in the Polls context.

PollChoices

A block tag to enter the choice context. Must be used in the Polls context. Choices are returned in the same order they are shown on the Edit screen.

PollChoiceID

Returns the id of the current choice. As with PollID this tag is important because it helps create a unique form. Must be used in the PollChoices context.

PollChoiceText

Returns the text label of the current choice. Must be used in the PollChoices context.

PollChoiceVotes

Returns a count of the total number of votes received by the choice. Must be used in the PollChoices context.

PollSelectedChoiceID

This tag returns the ID of the Choice the user selected. This tag is only useful in the Results Template, to display or highlight the response the user selected.

PollSelectedChoiceText

This tag returns the label text of the Choice the user selected. This tag is only useful in the Results Template, to display or highlight the response the user selected.

QuizCorrectChoiceID

When creating a quiz the correct choice must be selected so that Poll Position can tell if the user chose properly. This tag returns the ID of the correct choice.

QuizCorrectChoiceText

When creating a quiz the correct choice must be selected so that Poll Position can tell if the user chose properly. This tag returns the label text of the correct choice.

PollChartImage

Use this tag in the Poll Position Results template to return the URL to a Google Chart. This tag uses the chart options found in the plugin’s Settings to generate the image.

PollDisplayResults

Combine this tag with an If statement to display different poll results on your Main Index and Entry pages, for example. Supply a value in the display_results poll form element, which gets passed into the PollDisplayResults tag. Read more about the Results Template capabilities below.

PollStatus

This tag returns the numeric status of the poll in context. Possible values are “0” (closed for voting), “1” (open for voting) and “2” (unpublished). Use these values to control the poll display, showing only results and no voting form for polls with voting that is closed.