Skip to content

Commit

Permalink
[#2801] Documented the related item snippets
Browse files Browse the repository at this point in the history
Also updated an instance of {% include %} to use snippets
  • Loading branch information
aron committed Aug 9, 2012
1 parent ea10c78 commit 4c176ff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
16 changes: 14 additions & 2 deletions ckan/templates/related/snippets/related_item.html
@@ -1,7 +1,19 @@
{#
Displays a single related item.

related - The related item dict.
pkg_id - The id of the owner package. If present the edit button will be
displayed.

Example:



#}
{% set placeholder_map = {
'application':'/base/images/placeholder-application.png'
} %}
<li class="related-item media-item media media-vertical{% if first %} first{% endif %}{% if last %} last{% endif %}">
<li class="related-item media-item media media-vertical{% if first %} first{% endif %}{% if last %} last{% endif %}" data-module="related-item">
<a class="media-image" href="{{ related.url }}">
<img src="{{ related.image_url or placeholder_map[related.type] or '/base/images/placeholder-image.png' }}" alt="{{ related.title }}" />
<span class="banner">
Expand All @@ -27,7 +39,7 @@ <h3 class="media-heading">
{% endif %}
<a class="btn btn-small btn-primary" href="{{ related.url }}" target="_blank">{{ _('Go to {type}').format(type=related.type|replace('_', ' ')|title) }}</a>
{% if pkg_id %}
{{ h.nav_link(_('Edit'), controller='related', action='edit', id=pkg_id, related_id=related.id, class_='btn btn-small') }}
{{ h.nav_link(_('Edit'), controller='related', action='edit', id=pkg_id, related_id=related.id, class_='btn btn-small') }}
{% endif %}
</div>
</li>
17 changes: 16 additions & 1 deletion ckan/templates/related/snippets/related_list.html
@@ -1,7 +1,22 @@
{#
Renders a list of related item elements

related_items - A list of related items.
pkg_id - A package id for the items used to determine if the edit button
should be displayed.
first - True if the first item in a row.
last - True if the last item in a row.

Example:


{% snippet "related/snippets/related_list.html", related_items=c.pkg.related, pkg_id=c.pkg.name %}

#}
<ul class="media-grid">
{% for related in related_items %}
{% set first = loop.index0 % 3 == 0 %}
{% set last = loop.index0 % 3 == 2 %}
{% include "related/snippets/related_item.html" %}
{% snippet "related/snippets/related_item.html", pkg_id=pkg_id, related=related, first=first, last=last %}
{% endfor %}
</ul>

0 comments on commit 4c176ff

Please sign in to comment.