Polls
{* Saurus CMS polls sample, written in Saurus API *}
{init_objects name="polls" classes="poll"}
{*********** loop over polls **********}
{foreach from=$polls item=poll}
{init_object name="object" id=$poll->id}
<h1>{$object->buttons}{$poll->title}</h1>
{********* VOTING *********}
{**** 1. RESULTS: if user is already VOTED or poll is EXPIRED or in editor-area *}
{if $object->is_voted || $object->is_expired || $in_editor}
<h2>Results:</h2>
<ol>
{foreach from=$object->answers item=answer}
<li>{$answer->title} - <strong>{$answer->count}</strong></li>
{/foreach}
</ol>
{**** 2. VOTE FORM: if user is NOT VOTED and poll is NOT EXPIRED *}
{else}
<form action="{$self}" method="GET">
<input type="hidden" name="uri" value="{$url}">
<input type="hidden" name="gallup_id" value="{$object->id}">
<input type="hidden" name="op" value="vote">
<ol>
{foreach from=$object->answers item=answer}
<li>
<input type="radio" id="vastus_{$answer->id}" name="vastus" value= "{$answer->id}">
<label for="vastus_{$answer->id}">{$answer->title}</label>
</li>
{/foreach}
</ol>
<input type="submit" name="haaleta" value="Vote">
</form>
{/if} {*user is voted or not*}
{********* SHOW VOTERS INFO if not anonymous poll *********}
{if !$object->is_anonymous}
<h2>Voters list</h2>:
<ol>
{foreach from=$object->voters item=voter}
<li>{$voter->user_firstname} {$voter->user_lastname} ({$voter->time})</li>
{/foreach}
</ol>
{/if}
{foreachelse}
{$polls_newbutton}
{/foreach}
{*********** loop over polls **********}