Skip to content

Commit

Permalink
[#1301] Added a few template blocks to the facet lists
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Nov 14, 2013
1 parent a434ebb commit 011973d
Showing 1 changed file with 50 additions and 42 deletions.
92 changes: 50 additions & 42 deletions ckan/templates/snippets/facet_list.html
Expand Up @@ -37,46 +37,54 @@
page and not the left column.

#}
{% set hide_empty = hide_empty or false %}
{% with items = items or h.get_facet_items_dict(name) %}
{% if items or not hide_empty %}
{% if within_tertiary %}
{% set nav_class = 'nav nav-pills nav-stacked' %}
{% set nav_item_class = ' ' %}
{% set wrapper_class = 'nav-facet nav-facet-tertiary' %}
{% endif %}
<section class="{{ wrapper_class or 'module module-narrow module-shallow' }}">
<h2 class="module-heading">
<i class="icon-medium icon-filter"></i>
{% set title = title or h.get_facet_title(name) %}
{{ title }}
</h2>
{% if items %}
<nav>
<ul class="{{ nav_class or 'unstyled nav nav-simple nav-facet' }}">
{% for item in items %}
{% set href = h.remove_url_param(name, item.name, extras=extras, alternative_url=alternative_url) if item.active else h.add_url_param(new_params={name: item.name}, extras=extras, alternative_url=alternative_url) %}
{% set label = label_function(item) if label_function else item.display_name %}
{% set label_truncated = h.truncate(label, 22) if not label_function else label %}
{% set count = count_label(item['count']) if count_label else ('(%d)' % item['count']) %}
<li class="{{ nav_item_class or 'nav-item' }}{% if item.active %} active{% endif %}">
<a href="{{ href }}" title="{{ label if label != label_truncated else '' }}">
<span>{{ label_truncated }} {{ count }}</span>
</a>
</li>
{% endfor %}
</ul>
</nav>
<p class="module-footer">
{% if h.get_param_int('_%s_limit' % name) %}
<a href="{{ h.remove_url_param('_%s_limit' % name, replace=0, extras=extras, alternative_url=alternative_url) }}" class="read-more">{{ _('Show More {facet_type}').format(facet_type=title) }}</a>
{% else %}
<a href="{{ h.remove_url_param('_%s_limit' % name, extras=extras, alternative_url=alternative_url) }}" class="read-more">{{ _('Show Only Popular {facet_type}').format(facet_type=title) }}</a>
{% endif %}
</p>
{% else %}
<p class="module-content empty">{{ _('There are no {facet_type} that match this search').format(facet_type=title) }}</p>
{% block facet_list %}
{% set hide_empty = hide_empty or false %}
{% with items = items or h.get_facet_items_dict(name) %}
{% if items or not hide_empty %}
{% if within_tertiary %}
{% set nav_class = 'nav nav-pills nav-stacked' %}
{% set nav_item_class = ' ' %}
{% set wrapper_class = 'nav-facet nav-facet-tertiary' %}
{% endif %}
</section>
{% endif %}
{% endwith %}
{% block facet_list_item %}
<section class="{{ wrapper_class or 'module module-narrow module-shallow' }}">
{% block facet_list_heading %}
<h2 class="module-heading">
<i class="icon-medium icon-filter"></i>
{% set title = title or h.get_facet_title(name) %}
{{ title }}
</h2>
{% endblock %}
{% block facet_list_items %}
{% if items %}
<nav>
<ul class="{{ nav_class or 'unstyled nav nav-simple nav-facet' }}">
{% for item in items %}
{% set href = h.remove_url_param(name, item.name, extras=extras, alternative_url=alternative_url) if item.active else h.add_url_param(new_params={name: item.name}, extras=extras, alternative_url=alternative_url) %}
{% set label = label_function(item) if label_function else item.display_name %}
{% set label_truncated = h.truncate(label, 22) if not label_function else label %}
{% set count = count_label(item['count']) if count_label else ('(%d)' % item['count']) %}
<li class="{{ nav_item_class or 'nav-item' }}{% if item.active %} active{% endif %}">
<a href="{{ href }}" title="{{ label if label != label_truncated else '' }}">
<span>{{ label_truncated }} {{ count }}</span>
</a>
</li>
{% endfor %}
</ul>
</nav>
<p class="module-footer">
{% if h.get_param_int('_%s_limit' % name) %}
<a href="{{ h.remove_url_param('_%s_limit' % name, replace=0, extras=extras, alternative_url=alternative_url) }}" class="read-more">{{ _('Show More {facet_type}').format(facet_type=title) }}</a>
{% else %}
<a href="{{ h.remove_url_param('_%s_limit' % name, extras=extras, alternative_url=alternative_url) }}" class="read-more">{{ _('Show Only Popular {facet_type}').format(facet_type=title) }}</a>
{% endif %}
</p>
{% else %}
<p class="module-content empty">{{ _('There are no {facet_type} that match this search').format(facet_type=title) }}</p>
{% endif %}
{% endblock %}
</section>
{% endblock %}
{% endif %}
{% endwith %}
{% endblock %}

0 comments on commit 011973d

Please sign in to comment.