search_results.html 5.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {% extends "base.html" %}
  2. {% block title %}Search{% if search_results %} results{% endif %}{% if search_query %} for “{{ search_query }}”{% endif %}{% endblock %}
  3. {% block search_description %}Search{% if search_results %} results{% endif %}{% if search_query %} for “{{ search_query }}”{% endif %}{% endblock %}
  4. {% block body_class %}template-search-results{% endblock %}
  5. {% block content %}
  6. <div class="container">
  7. <div class="row">
  8. <div class="col-md-8">
  9. <h1>Search results</h1>
  10. {% if search_results %}
  11. <p class="search__introduction">You searched{% if search_query %} for “{{ search_query }}”{% endif %}, {{ search_results|length }} result{{ search_results|length|pluralize }} found.</p>
  12. <ul class="search__results">
  13. {% for result in search_results %}
  14. <li class="listing-card">
  15. <a class="listing-card__link" href="{{ pageurl(result.specific) }}">
  16. {% if result.specific.image %}
  17. <figure class="listing-card__image">
  18. {{ image(result.specific.image, "fill-180x180-c100", loading="lazy") }}
  19. </figure>
  20. {% endif %}
  21. <div class="listing-card__contents">
  22. <h3 class="listing-card__title">{{ result.specific }}</h3>
  23. <p class="listing-card__content-type">
  24. {% if result.specific.content_type.model == "blogpage" %}
  25. Blog Post
  26. {% elif result.specific.content_type.model == "locationpage" %}
  27. Location
  28. {% else %}
  29. Bread
  30. {% endif %}
  31. </p>
  32. <p class="listing-card__description">
  33. {% if result.specific.search_description %}{{ result.specific.search_description|richtext }}{% endif %}
  34. </p>
  35. </div>
  36. </a>
  37. </li>
  38. {% endfor %}
  39. </ul>
  40. {% elif search_query %}
  41. {% set search_promotions=get_search_promotions(search_query) %}
  42. {% if search_promotions %}
  43. <p class="search__introduction">You searched for “{{ search_query }}”, {{ search_promotions|length }} result{{ search_promotions|length|pluralize }} found.</p>
  44. <ul class="search__results">
  45. {% for search_promotion in search_promotions %}
  46. <li class="listing-card">
  47. <a class="listing-card__link" href="{{ pageurl(search_promotion.page.specific) }}">
  48. {% if search_promotion.page.specific.image %}
  49. <figure class="listing-card__image">
  50. {{ image(search_promotion.page.specific.image, "fill-180x180-c100", loading="lazy") }}
  51. </figure>
  52. {% endif %}
  53. <div class="listing-card__contents">
  54. <h3 class="listing-card__title">{{ search_promotion.page.specific }}</h3>
  55. <p class="listing-card__content-type">
  56. {% if search_promotion.page.specific.content_type.model == "blogpage" %}
  57. Blog Post
  58. {% elif search_promotion.page.specific.content_type.model == "locationpage" %}
  59. Location
  60. {% else %}
  61. Bread
  62. {% endif %}
  63. </p>
  64. <p class="listing-card__description">
  65. {% if search_promotion.page.specific.search_description %}{{ search_promotion.page.specific.search_description|richtext }}{% endif %}
  66. </p>
  67. </div>
  68. </a>
  69. </li>
  70. {% endfor %}
  71. </ul>
  72. {% else %}
  73. <p class="search__introduction">No results found for “{{ search_query }}”.</p>
  74. {% endif %}
  75. {% else %}
  76. <p class="search__introduction">You didn&apos;t search for anything!</p>
  77. {% endif %}
  78. </div>
  79. </div>
  80. </div>
  81. {% endblock content %}