{% extends 'layout.html.twig' %}

{% block title %}{{'课程'|trans}} - {{ parent() }}{% endblock %}
{% set nav = 'course' %}

{% set bodyClass = 'homepage' %}

{% block content %}
  <p>{{'请创建模版文件'|trans}}customize/content/{{ type }}/list.html.twig，{{'自定义'|trans}}。</p>
  <div class="row es-row-light">



    <div class="col-md-8">

      <div class="panel panel-default panel-primary">
        <div class="panel-heading"><h2>{{'最新文章'|trans}}</h2></div>

        <ul class="media-list content-list article-list">
          {% for content in contents %}
            {% set contentCategory = categories[content.categoryId]|default(null)  %}
            <li class="media">
              {% if content.picture %}
              <a class="pull-right" href="#">
                <img class="media-object" src="{{ filepath(content.picture) }}">
              </a>
              {% endif %}
              <div class="media-body">
                <h4 class="media-heading"><a href="{{ path('content_article_show', {alias:content.alias|default(content.id)}) }}">{{ content.title }}</a></h4>
                {{ content.body|plain_text(120) }}
                <div class="color-gray">
                  <span class="color-gray">{{'发布于'|trans}} {{ content.publishedTime|date('Y-n-d') }}</span>
                  {% if contentCategory %}
                    <span>, {{'属于'|trans}} <a href="#" class="color-gray">{{ contentCategory.name }}</a> {{'分类'|trans}}</span>
                  {% endif %}
                </div>
              </div>
            </li>
          {% endfor %}
        </ul>
        <nav class="text-center">
          {{ web_macro.paginator(paginator) }}
        </nav>
      </div>
    </div>

    <div class="col-md-4">
      <div class="panel panel-default">
        <div class="panel-heading">{{'分类'|trans}}</div>

          <div class="list-group list-group-flush">
            {% for category in categoryTree %}
              <a href="{{ path('content_article_list', {categoryId:category.id}) }}" class="list-group-item">{{ category.name }}</a>
              {% endfor  %}
          </div>

      </div>

    </div>
  </div>
{% endblock %}