search_results.html 5.2 KB

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