{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% block meta_title %}{{ 'Knowledge base'|trans }}{% endblock %}

{% block content %}
    {% if request.q %}
        {% set kbcategories = guest.kb_category_get_list({"q": request.q}) %}
    {% else %}
        {% set kbcategories = guest.kb_category_get_list %}
    {% endif %}

<div class="h-block" >
    <div class="h-block-header">
        <div class="icon"><span class="big-light-icon i-kb"></span></div>
        <h2>{{ 'Knowledge base'|trans }}</h2>
    </div>
    <div class="block">
        <div class="block" style="text-align: center; margin: 20px 0 20px 0">
            <form method="get" action="{{ 'kb'|link }}" class="search">
                <p>
                    <input class="search text" name="q" type="text" value="{{ request.q }}" placeholder="{{ 'What are you looking for?'|trans }}">
                    <input class="bb-button bb-button-submit" value="{{ 'Search'|trans }}" type="submit">
                </p>
            </form>
        </div>

    {% for i, category in kbcategories.list %}
        <div class="block kb">
            <h2 class="big-dark-icon i-kb" id="category-{{category.id}}"><a href="{{ 'kb'|link }}/{{ category.slug }}">{{category.title}}</a></h2>
            <ul>
            {% for i, article in category.articles %}
                <li><a href="{{ '/kb'|link }}/{{ article.category.slug }}/{{ article.slug }}">{{article.title}}</a></li>
            {% endfor %}
            </ul>
        </div>
    {% else %}
        <p>
            {{ 'Try using other keyword. No matches not for keyword:'|trans }}
            <b>{{ request.q }}</b>
        </p>
    {% endfor %}
    </div>
</div>
{% endblock %}
