From: Karen Rustad Date: Wed, 3 Aug 2011 01:01:02 +0000 (-0700) Subject: adds feature #458 -- given a column number, limits the number of items in a row ... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=035c976fb2ccbbc7dc73cc6ceb4b5ed8d4523561;p=mediagoblin.git adds feature #458 -- given a column number, limits the number of items in a row (and adds divs saying so). No CSS styling to make these demarcations visible, though --- diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index 03b85b17..c5e890fc 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -18,15 +18,46 @@ {% from "mediagoblin/utils/pagination.html" import render_pagination %} +{% macro media_grid(media_list, col_number=5) %} + {% set num_items = media_list.count() %} + {% set col_counter = 0 %} + {% set row_counter = 0 %} + {% set item_counter = 0 %} + + {% set num_rows = num_items // col_number %} + {% if num_items % col_number != 0 %} + {% set num_rows = num_rows + 1 %} + {% endif %} + + +{%- endmacro %} + {% block object_gallery_content -%} {% if media_entries and media_entries.count() %} - {% for entry in media_entries %} -
- - -
- {% endfor %} + {{ media_grid(media_entries) }}
{% if pagination_base_url %} {# different url, so set that and don't keep the get params #}