Skip to content

Instantly share code, notes, and snippets.

@andershaig
Created June 21, 2012 20:05
Show Gist options
  • Select an option

  • Save andershaig/2968228 to your computer and use it in GitHub Desktop.

Select an option

Save andershaig/2968228 to your computer and use it in GitHub Desktop.
Voting with Categories Example
{% plugin voting my_voting %}
{% marker my_voting %}
<div class="voting">
{% formblock my_voting %}
{% if my_voting.has_categories %}
{% for category in my_voting.categories %}
<div class="category">
<h1>{{ category.title }}</h1>
{% for entry in category.entries %}
<div class="entry">
<div class="voting_body">{{ entry.body }}</div>
<h3 class="voting_title">{{ entry.title }}</h3>
<div class="voting_button">
{% if my_voting.completed %}
<!-- no more votes available for the plugin; show results -->
{{ entry.result }}
{% elsif entry.completed %}
<!-- user has already voted on this entry; show a text or checkmark or something, but not the final results yet -->
<p>Voted!</p>
{% else %}
{{ entry.vote_button }}
{% endif %}
</div>
</div><!-- end .entry -->
{% endfor %}
</div><!-- end .category -->
{% endfor %}
{% else %}
{% for entry in my_voting.entries %}
<div class="entry">
<div class="voting_body">{{ entry.body }}</div>
<h3 class="voting_title">{{ entry.title }}</h3>
<div class="voting_button">
{% if my_voting.completed %}
<!-- no more votes available for the plugin; show results -->
{{ entry.result }}
{% elsif entry.completed %}
<!-- user has already voted on this entry; show a text or checkmark or something, but not the final results yet -->
<p>Voted!</p>
{% else %}
{{ entry.vote_button }}
{% endif %}
</div>
</div><!-- end .entry -->
{% endfor %}
{% endif %}
<div class="sharing">{{ my_voting.share_confirmation }}</div>
{% endformblock %}
</div><!-- end .voting -->
{% endmarker %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment