templates/ContentBlock/results.html.twig line 1

Open in your IDE?
  1. {% if aParams.search_terms_caption is not defined or (aParams.search_terms_caption is defined and aParams.search_terms_caption) %}
  2.     {% if aParams.search_terms is defined and aParams.search_terms and aParams.page == 1 %}
  3.         <div class="_search_totals alert alert-warning">
  4.             <span>Search results for: </span><b>{{ aParams.search_terms }}</b>
  5.             {% if all_results.total_results is defined %}
  6.                 <br />
  7.                 <span>{{ all_results.total_results }} results found</span>
  8.             {% endif %}
  9.         </div>
  10.     {% elseif aParams.show_total_results is defined and aParams.show_total_results and aParams.page == 1 and all_results.total_results is defined %}
  11.         <div class="_search_totals alert alert-warning">
  12.             <span>{{ all_results.total_results }} results found</span>
  13.         </div>
  14.     {% endif %}
  15. {% endif %}
  16. {% if aParams.double_pagination is defined and aParams.double_pagination %}
  17.     {% if pagination %}
  18.         {% if aParams.show_pagination is defined and aParams.show_pagination %}
  19.             <div class="_pagination" style="{{ aParams.infinite_scroll is defined and aParams.infinite_scroll ? 'display: none;' : '' }}">
  20.                 {{ knp_pagination_render(pagination, aParams.pagination_template) }}
  21.             </div>
  22.         {% endif %}
  23.     {% endif %}
  24. {% endif %}
  25. {% if results|length %}
  26.     {% if aParams.renderMode is defined and aParams.renderMode == 'table' %}
  27.         <table class="_table">
  28.             {% if aParams.tableHeaders is defined %}
  29.                 <thead>
  30.                     <tr>
  31.                         {% for tableHeader in aParams.tableHeaders %}
  32.                             {% set colWidth = aParams.tableWidths is defined ? aParams.tableWidths[loop.index0] : '' %}
  33.                             <th {{ colWidth ? ('style="width: '~colWidth~'"')|raw : '' }}>{{ tableHeader|capitalize }}</th>
  34.                         {% endfor %}
  35.                     </tr>
  36.                 </thead>
  37.             {% endif %}
  38.             {% for result in results %}
  39.                 <tbody>
  40.                     {% if aParams.item_source is defined and aParams.item_source %}
  41.                         {{ include(template_from_string(aParams.item_source), {
  42.                             'item': result,
  43.                             'aParams': aParams,
  44.                             'result_idx': loop.index
  45.                         }) }}
  46.                     {% else %}
  47.                         {% include aParams.item_template with {
  48.                             'item': result,
  49.                             'aParams': aParams,
  50.                             'result_idx': loop.index
  51.                         } %}
  52.                     {% endif %}
  53.                 </tbody>
  54.             {% endfor %}
  55.         </table>
  56.     {% else %}
  57.         <div class="_results _results_{{ aParams.contentType }} {{ aParams.results_items_wrapper_class is defined ? aParams.results_items_wrapper_class : '' }}">
  58.             {% for result in results %}
  59.                 {% if aParams.item_source is defined and aParams.item_source %}
  60.                     <div class="_results_item _results_{{ aParams.contentType }}_item">
  61.                         {{ include(template_from_string(aParams.item_source), {
  62.                             'item': result,
  63.                             'aParams': aParams,
  64.                             'result_idx': loop.index
  65.                         }) }}
  66.                     </div>
  67.                 {% else %}
  68.                     <div class="_results_item _results_{{ aParams.contentType }}_item {{ aParams.results_item_class is defined ? aParams.results_item_class : '' }}">
  69.                         {% include aParams.item_template with {
  70.                             'item': result,
  71.                             'aParams': aParams,
  72.                             'result_idx': loop.index
  73.                         } %}
  74.                     </div>
  75.                 {% endif %}
  76.             {% endfor %}
  77.         </div>
  78.     {% endif %}
  79. {% else %}
  80.     {% if aParams.remove_block_if_no_results is defined and aParams.remove_block_if_no_results %}
  81.         {% if aParams.container_id is defined and aParams.container_id %}
  82.             <script>
  83.                 $('div[data-container-id="{{ aParams.container_id }}"]').remove();
  84.             </script>
  85.         {% endif %}
  86.     {% elseif aParams.hide_block_if_no_results is defined and aParams.hide_block_if_no_results %}
  87.         {% if aParams.container_id is defined and aParams.container_id %}
  88.             <script>
  89.                 $('div[data-container-id="{{ aParams.container_id }}"]').hide();
  90.             </script>
  91.         {% endif %}
  92.     {% elseif aParams.page == 1 %}
  93.         {% if aParams.no_results_template is defined and aParams.no_results_template %}
  94.             {% include aParams.no_results_template %}
  95.         {% else %}
  96.             <div class="_no_results">
  97.                 {% if aParams.no_results_html is defined and aParams.no_results_html %}
  98.                     {{ aParams.no_results_html|raw }}
  99.                 {% else %}
  100.                     <div class="_noContent text-center">
  101.                         {#<span>No results to show ;(</span>#}
  102.                         {#
  103.                         <img src="{{ asset('img/no_results_found.webp') }}" style="opacity: .8;" />
  104.                         #}
  105.                         <i class="fas fa-search mt-5 mb-4" style="font-size: 2.5em;"></i>
  106.                         <h5>No results found</h5>
  107.                     </div>
  108.                 {% endif %}
  109.             </div>
  110.         {% endif %}
  111.         {# Suggested results #}
  112.         {% if results_suggested is defined and results_suggested and results_suggested|length %}
  113.             <div class="search_results_suggested" style="float: left; padding: 20px 20px 0;">
  114.                 <span>You might be interested in:</span>
  115.             </div>
  116.             <div class="_results _results_{{ aParams.contentType }}">
  117.                 {% for result in results_suggested %}
  118.                     {% if aParams.item_source is defined and aParams.item_source %}
  119.                         <div class="_results_item _results_{{ aParams.contentType }}_item">
  120.                             {{ include(template_from_string(aParams.item_source), {
  121.                                 'item': result,
  122.                                 'aParams': aParams,
  123.                                 'result_idx': loop.index
  124.                             }) }}
  125.                         </div>
  126.                     {% else %}
  127.                         <div class="_results_item _results_{{ aParams.contentType }}_item">
  128.                             {% include aParams.item_template with {
  129.                                 'item': result,
  130.                                 'aParams': aParams,
  131.                                 'result_idx': loop.index
  132.                             } %}
  133.                         </div>
  134.                     {% endif %}
  135.                 {% endfor %}
  136.             </div>
  137.         {% endif %}
  138.     {% endif %}
  139. {% endif %}
  140. {% if pagination %}
  141.     {% if aParams.show_pagination is defined and aParams.show_pagination %}
  142.         <div class="_pagination mt-4" style="{{ aParams.infinite_scroll is defined and aParams.infinite_scroll ? 'display: none;' : '' }}">
  143.             {{ knp_pagination_render(pagination, aParams.pagination_template) }}
  144.         </div>
  145.     {% endif %}
  146. {% endif %}