<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="here/main_template/macros/master"
      i18n:domain="collective.tiles.collection">
    <body>
        <metal:macro define-macro="collection-tile-macro"
                     tal:define="helper_view nocall:context/@@collection_tile_helpers;">
        <div class="aree-tematiche-collection">
            <h2 tal:define="title view/data/title|nothing;"
                class="tileTitle"
                tal:condition="title">${title}</h2>
            <div class="tileBody">
                <p tal:condition="not:results"
                   class="noResults"
                   i18n:translate="tiles_collection_noresults">
                    No results found
                </p>
                <ul class="tileContent" tal:condition="results">
                    <tal:results tal:repeat="obj results">
                    <li tal:define="oddrow repeat/obj/odd;
                                    useView python:obj.portal_type in viewActions;
                                    itemUrl python:useView and obj.getURL() + '/view' or obj.getURL();
                                    portal_url context/portal_url;
                                    is_external_link python: helper_view.is_external_link(obj);
                                    item_wf_state obj/review_state;
                                    item_wf_state_class python:'state-' + plone_view.normalizeString(item_wf_state);
                                    item_type obj/portal_type;
                                    item_type_class python:'contenttype-' + plone_view.normalizeString(item_type);"
                        tal:attributes="class python: oddrow and 'collectionItem even' or 'collectionItem odd'">
                        <div class="linkWrapper">
                            <a href="#"
                               tal:attributes="href itemUrl;
                                               target python: is_external_link and '_blank' or None;
                                               rel python: is_external_link and 'noopener noreferrer' or None;
                                               class string:tile $item_type_class $item_wf_state_class;
                                               title obj/Description">

                                <?python
                                    item = obj.getObject()
                                    hasImage = False
                                    try:
                                        if item.image:
                                            hasImage = True
                                    except AttributeError:
                                        hasImage = False
                                ?>

                                <div class="linkImage"
                                     tal:condition="hasImage"
                                     tal:define="icon python:obj.getURL()+'/@@images/image/icon'">
                                  <img class="link-icon" tal:attributes="src string:$icon;" alt="${obj/Title|nothing}" />
                                </div>
                                <div class="linkText">
                                    <span class="title">
                                       <span tal:replace="obj/Title"> Title </span>
                                    </span>
                                </div>
                            </a>
                        </div>
                    </li>
                    </tal:results>
                </ul>
                <div class="showMore"
                     tal:define="show_more view/data/show_more;
                                 title view/data/title"
                     tal:condition="python: show_more and title">
                    <a href="${collection/absolute_url}"
                       tal:define="show_more_label view/data/show_more_label|nothing">
                        <span tal:condition="not:show_more_label"
                              i18n:translate="more_url">More&hellip;</span>
                        <span tal:condition="show_more_label">${show_more_label}</span>
                    </a>
                </div>
            </div>
        </div>
        </metal:macro>
    </body>
</html>
