0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 11:10:43 +01:00
wagtail/docs/reference/contrib/searchpromotions.rst

60 lines
1.8 KiB
ReStructuredText
Raw Normal View History

2015-07-06 12:35:38 +02:00
.. _editors-picks:
=======================
Promoted search results
=======================
.. module:: wagtail.contrib.search_promotions
2015-07-06 12:35:38 +02:00
The ``searchpromotions`` module provides the models and user interface for managing "Promoted search results" and displaying them in a search results page.
2015-07-06 12:35:38 +02:00
"Promoted search results" allow editors to explicitly link relevant content to search terms, so results pages can contain curated content in addition to results from the search engine.
Installation
============
The ``searchpromotions`` module is not enabled by default. To install it, add ``wagtail.contrib.search_promotions`` to ``INSTALLED_APPS`` in your project's Django settings file.
2015-07-06 12:35:38 +02:00
.. code-block:: python
INSTALLED_APPS = [
...
'wagtail.contrib.search_promotions',
2015-07-06 12:35:38 +02:00
]
This app contains migrations so make sure you run the ``migrate`` django-admin command after installing.
Usage
=====
Once installed, a new menu item called "Promoted search results" should appear in the "Settings" menu. This is where you can assign pages to popular search terms.
Displaying on a search results page
-----------------------------------
To retrieve a list of promoted search results for a particular search query, you can use the ``{% get_search_promotions %}`` template tag from the ``wagtailsearchpromotions_tags`` templatetag library:
2015-07-06 12:35:38 +02:00
.. code-block:: html+django
2015-07-06 12:35:38 +02:00
{% load wagtailcore_tags wagtailsearchpromotions_tags %}
2015-07-06 12:35:38 +02:00
...
{% get_search_promotions search_query as search_promotions %}
2015-07-06 12:35:38 +02:00
<ul>
{% for search_promotion in search_promotions %}
2015-07-06 12:35:38 +02:00
<li>
<a href="{% pageurl search_promotion.page %}">
<h2>{{ search_promotion.page.title }}</h2>
<p>{{ search_promotion.description }}</p>
2015-07-06 12:35:38 +02:00
</a>
</li>
{% endfor %}
</ul>