Can't display category image

37 views
Skip to first unread message

Nuruddin Iminohunov

unread,
Jun 24, 2016, 6:57:59 PM6/24/16
to django-oscar
I have the following code to print categories in the first level and subcategories as dropdown menu, however, subcategory image is only shown for the first picture only here the rest is not shown.
Please help.  I attached a picture as a result


{% category_tree depth=2 as tree_categories %}
{% for category, info in tree_categories %}
{% if info.level == 0 %}
<li><a href="{{ category.get_absolute_url }}"><i
class="fa fa-{{ category.icon }} dropdown-menu-category-icon"></i>{{ category.name }} </a>
{% if info.has_children %}
<div class="dropdown-menu-category-section">
<div class="dropdown-menu-category-section-inner">
<div class="dropdown-menu-category-section-content">
<div class="row">
{% category_tree depth=1 parent=category as sub_categories %}
{% for sub_category, info in sub_categories %}
<div class="col-md-4">
<a href="{{ sub_category.get_absolute_url }}">
<h5 class="dropdown-menu-category-title">

{% thumbnail sub_category.image "100x100" upscale=False as thumb %}
<img
src="{{ thumb.url }}"
alt="{{ sub_category.name }}"
title="{{ sub_category.name }}"
/>
{% endthumbnail %}
{{ sub_category.name }}

</h5>
</a>
<ul class="dropdown-menu-category-list">
{% category_tree depth=1 parent=sub_category as sub_sub_categories %}
{% for ss_category, info in sub_sub_categories %}
<li>
<a href="{{ ss_category.get_absolute_url }}">{{ ss_category.name }}</a>
<p>{{ ss_category.description|safe }}</p>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% if info.level == 0 %}
{% thumbnail category.image "300x300" upscale=False as thumb %}
<img class="dropdown-menu-category-section-theme-img"
src="{{ thumb.url }}"
alt="{{ category.name }}" title="{{ category.name }}"
style="right: 10px;"/>
{% endthumbnail %}
{% endif %}
</div>
</div>
{% endif %}
</li>

{% endif %}
{% endfor %}
Reply all
Reply to author
Forward
0 new messages