{% load i18n cyclope_utils %}

{% with content_relations=current_object.related_contents.all  %}
  {% if content_relations %}
  {% regroup content_relations by other_type as relations %}
  <div class="related_contents">
    <span class="title">{% trans "Related:" %} </span>
    <ul>
    {% for relation in relations %}
      <li class='related_type {{ relation.grouper }}'>
        <ul>
        {% for rel in relation.list %}
            {% with current_object=rel.other_object %}
                <li class='related_content {{ current_object.get_object_name }}'>
                    <img class="type_icon" src="{{ CYCLOPE_THEME_MEDIA_URL }}images/icons/{{ current_object.get_object_name }}.png" />
                    <a href="{{ current_object.get_absolute_url }}">{{ current_object.name }} </a>
                        {% if current_object.media_file %}
                            <a target="_blank" href="{{ current_object.media_file }}">({% trans "download file" %})</a>
                        {% endif %}
                    {% with type=current_object.get_object_name player_video_height='180' player_video_width='240' %}
                        {% if type == 'soundtrack' or type == 'movieclip' %}
                            {% include 'medialibrary/media_player.html' %}
                        {% endif %}
                    {% endwith %}
                </li>
            {% endwith %}
        {% endfor %}
      </ul>
      </li>
    {% endfor %}
    </ul>
  </div>
  {% endif %}
{% endwith %}
