{% extends "layout_2_col.html" %}

{% load basket_tags %}
{% load promotion_tags %}
{% load category_tags %}
{% load product_tags %}
{% load i18n %}
{% block title %}
    {{ summary }} | {{ block.super }}
{% endblock %}

{% block description %}
    {{ category.description|default:""|striptags }}
{% endblock %}

{% block headertext %}{{ summary }}{% endblock %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{{ homepage_url }}">{% trans "Home" %}</a>
            <span class="divider">/</span>
        </li>
        {% if not category %}
            <li class="active">{% trans "All products" %}</li>
        {% else %}
            {% for category in category.get_ancestors|slice:":-1" %}
                <li>
                    <a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
                    <span class="divider">/</span>
                </li>
            {% endfor %}
            <li class="active">{{ category.name }}</li>
        {% endif %}
    </ul>
{% endblock breadcrumbs %}

{% block column_left %}
    {% category_tree as tree_categories %}
    {% if tree_categories %}
        <div class="side_categories" style="padding: 8px 0;">
            <ul class="nav nav-list">
                <li class="nav-header">{% trans "Browse categories" %}</li>
                {% for tree_category, info in tree_categories %}
                    <li>
                    {% if tree_category.pk == category.pk %}
                        <strong>{{ tree_category.name }}</strong>
                    {% else %}
                        <a href="{{ tree_category.get_absolute_url }}">{{ tree_category.name }}</a>
                    {% endif %}

                    {% if info.has_children %}<ul>{% else %}</li>{% endif %}
                    {% for n in info.num_to_close %}
                        </ul></li>
                    {% endfor %}
                {% endfor %}
            </ul>
        </div>
    {% endif %}
{% endblock %}

{% block content %}
    {% if category.description %}
        <div class="row-fluid">
            <div class="span9"><p>{{ category.description|safe }}</p></div>
            {% if category.image %}
                <div class="span3"><img src="{{ category.image.url }}" alt="{{ summary }}" /></div>
            {% endif %}
        </div>
    {% endif %}

    {% if products %}
        <section>
            <div>
                <ol class="row-fluid">
                    {% for product in products %}
                        <li class="span3 {% if forloop.counter0|divisibleby:"4" %}no-margin{% endif %}">{% render_product product %}</li>
                    {% endfor %}
                </ol>
                {% include "partials/pagination.html" %}
            </div>
        </section>
    {% else %}
        <p class="nonefound">{% trans "No products found." %}</p>
    {% endif %}
{% endblock content %}
