search_results.html 6.9 KB

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