search_results.html 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. {% image result.specific.image 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. <a class="listing-card__link" href="{% pageurl search_promotion.page.specific %}">
  49. {% if search_promotion.page.specific.image %}
  50. <figure class="listing-card__image">
  51. {% image search_promotion.page.specific.image fill-180x180-c100 loading="lazy" %}
  52. </figure>
  53. {% endif %}
  54. <div class="listing-card__contents">
  55. <h3 class="listing-card__title">{{ search_promotion.page.specific }}</h3>
  56. <p class="listing-card__content-type">
  57. {% if search_promotion.page.specific.content_type.model == "blogpage" %}
  58. Blog Post
  59. {% elif search_promotion.page.specific.content_type.model == "locationpage" %}
  60. Location
  61. {% else %}
  62. Bread
  63. {% endif %}
  64. </p>
  65. <p class="listing-card__description">
  66. {% if search_promotion.page.specific.search_description %}{{ search_promotion.page.specific.search_description|richtext }}{% endif %}
  67. </p>
  68. </div>
  69. </a>
  70. </li>
  71. {% endfor %}
  72. </ul>
  73. {% else %}
  74. <p class="search__introduction">No results found for “{{ search_query }}”.</p>
  75. {% endif %}
  76. {% else %}
  77. <p class="search__introduction">You didn&apos;t search for anything!</p>
  78. {% endif %}
  79. </div>
  80. </div>
  81. </div>
  82. {% endblock content %}