From 035c976fb2ccbbc7dc73cc6ceb4b5ed8d4523561 Mon Sep 17 00:00:00 2001 From: Karen Rustad Date: Tue, 2 Aug 2011 18:01:02 -0700 Subject: [PATCH] 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 --- .../mediagoblin/utils/object_gallery.html | 45 ++++++++++++++++--- 1 file changed, 38 insertions(+), 7 deletions(-) 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 #} -- 2.25.1