« Template Types | Main | Why QuickVote? »

Template Tags

This section summarizes all the dynamic template tags that are made available for templates. Although all of these variables may be used in all template types (i.e., form, result and archive), we tried to categorize them according to their most widely use.

About the usage of tags

All the tags described in this section are enclosed between [% and %] sequence of characters. For briefness the rest of this section does not mention nor display the proper use of tags. But when you see us talking about a tag poll.name, you should know that to use this tag, you have to insert it into your templates like so:

[% poll.name %]

The space between [% and the tag itself are insignificant, but case of the tags are important. Which means, poll.name, POLL.NAME and Poll.name are three different tags (of course, in our case, the latter two do not exist).

The best way of learning about templates and template tags is to look in the source of default Quick Vote templates. All the template tags can be used in all the templates (both result and form as well as archive templates), unless noted otherwise.

Poll details

  • poll.question

    Name or the question assigned to this poll.

  • poll.description

    If you assigned description to your poll while creating it, you can use this tag to display the description in your templates.

  • poll.id

    Numeric unique ID of the poll, assigned by the system.

  • poll.result_link

    Link leading to the page that displays poll's results.

  • poll.result_window_width

  • poll.result_window_height

    Suggested width and height of the result window, respectively. This is usually handy if you plan to display your results in a window opened through JavaScript's window.open() method, in which case it may be preferable to have a window open of a certain size. Both of these tags are suggestive, and not always accurate. You may even have to hard-code the window sizes in the form templates without having to rely on these suggestive values.

  • poll.total_hits

    Displays number of total hits the poll accumulated. In other words, it's the sum of unique hits each option received.

  • chart.img

    Replaced with <img> tag to display the result of the poll as a chart. The type of chart output for this tag is controlled from Quick Vote's control panel.

  • pie.img

    The same as chart.img, except this tag forces the result to be a pie chart, regardless of the settings in QuickVote's control panel

  • bars.img

    The same chart.img, except this tag forces the result to be vertical bars, regardless of the settings in QuickVote's control panel

  • cylinders.img

    The same as chart.img, except this tag forces the result to be vertical cylinder bars, regardless of the settings in QuickVote's control panel.

  • chart.src

  • pie.src

  • bars.src

  • cylinders.src

    Counterparts of the previous four tags. These are replaced with the URL of the respective charts. Handy if you wanted your <img /> tags displayed differently.

Poll Options

Since each poll may have different number of options, templates offer a set of container tags to display all the options that a poll may have. This container tag starts with [%FOREACH poll.choices%] and ends with [%END%]. The case is important. Everything between these two tags will be repeated for each option.

Following set of tags are available within this container:

  • option

    Replaced with the text of the option

  • id

    Numeric unique ID assigned by the system for this particular option.

  • color

    Hexadecimal color value assigned to each option. You can use this tag to color-code each option. Handy if you also wanted to display results chart with your form, so people know the result before they submit the poll. Go to the examples at the end of the section for ideas.

  • radio

    HTML Radio button generated for the option

  • checkbox

    HTML Checkbox generated for the option

  • hits

    Number of hits option has received

  • percentage

    Percentage value option's hits account for

  • bar.src

    URL of the colored bar, should you choose to express option's hits as a horizontal bar.

    This value can be used as following:

    <img src="[% bar_src %]" alt="[% hits %] hits ([% percentage %]%)" />

  • bar

    If the above example is all you need to display the bar chart, you might as well replace the previous example with just [% bar %], which generates the above <img> tag for you.

Other tags

  • form.action

    When you're writing your <form> tags, form.action will be replaced with the URL specific to the currently generated Poll that form needs to be submitted too. Tip: this is the same as the poll.result_link.

  • form.onsubmit

    If you want to rely on the suggested values of poll.resultwindowwidth and poll.resultwindowheight and want to display poll's results in a pop-up window, you may as well rely on this tag for convenience.

    Following is an example of the usage of the above two tags:

    <form method="post" action="[% form.action%]" onsubmit="[% form.onsubmit %]"> <!-- more stuff goes in here --> </form>

    This way, then the user submits the form, the results will be displayed in a pop-up window, size of which will be governed by the values returned from poll.resultwindowwidth and poll.resultwindowheight tags.

Pick your favorite Media Player

Windows Media Player
Winamp
QuickTime
Real Player
other