SearchΒΆ
Although many small sites won’t need it, every page on Glass is searchable.
To use search:
- Make a page with the path search
- In your template for that page, create a form with one input with name=”q”
- Iterate over the search hits in your template
Here is a very minimal example:
{% block content %}
<form method="get" action="/search">
<input type="search" name="q" value="{{ request.GET.q }}"><input type="submit" />
</form>
{% for result in results.hits.hits %}
<h1><a href=/{{ result.path }}?q={{ request.GET.q }}>{{ result.obj.content.title }}</a></h1>
{% for h in result.highlight.searchable_text %}
{{ h|striptags }}
{% if not forloop.last %}...{% endif %}
{% endfor %}
<hr/>
{% endfor %}
{% endblock %}
Search is backed by Elasticsearch and complex searching is available. If you need this please contact Issac for info.