templates/course/_materials.html.twig line 1

  1. {% for material in lecture.getFkLecture().getLectureMaterials() %}
        {% set icon = '' %}
        {% if material.type == 'image' %} {% set icon = 'ic_image.png' %}
        {% elseif material.type == 'file' %} {% set icon = 'ic_file.png' %}
        {% elseif material.type == 'url' %} {% set icon = 'ic_url.png' %}
        {% else %} {% set icon = 'ic_video.png' %}
        {% endif %}
    
        {% set local = false %}
        {% set titleMaterial = '' %}
        {% set descriptionMaterial = '' %}
    
        {% for materialTrans in material.getLectureMaterialsTranslates() %}
            {% if materialTrans.getFkLanguage().code == app.request.get('_locale') %}
                {% set titleMaterial = materialTrans.title %}
                {% set descriptionMaterial = materialTrans.description %}
                {% set local = true %}
            {% endif %}
        {% endfor %}
        {% if local == false %}
            {% for materialTrans in material.getLectureMaterialsTranslates()  %}
                {% if materialTrans.getFkLanguage().code == 'en' %}
                    {% set titleMaterial = materialTrans.title %}
                    {% set descriptionMaterial = materialTrans.description %}
                {% endif %}
            {% endfor %}
        {% endif %}
    
        <a href="{{ path('app_lecture_materials_show', {'course': course.id, 'lecture': lecture.getFkLecture().id, 'id': material.id}) }}">
            <article class="c-card-material">
                <div class="c-card-material__header">
                    <img class="c-card-material__image" src="{{ asset('custom/'~icon)}}"/>
                </div>
    
                <div class="c-card-material__body">
                    <span class="c-card-material__type">
                        {% if material.type == 'image' %} Image
                        {% elseif material.type == 'file' %} File
                        {% elseif material.type == 'url' %} Web
                        {% else %} Video
                        {% endif %}
                    </span>
                    <p class="c-card-material__title">{{ titleMaterial }}</p>
                    <div class="c-card-material__description">{{ descriptionMaterial|raw }}</div>
                    <span class="c-card-material__lang">EN</span>
                </div>
            </article>
        </a>
    {% endfor %}