Difference between revisions of "Search.liquid"
From Spiffy Stores Knowledge Base
(Created page with "This template is rendered to display the results of a search. If you do not provide a '''search.liquid''' template in your theme, a default system template will be used inste...") |
m |
||
Line 25: | Line 25: | ||
</div> | </div> | ||
</pre> | </pre> | ||
+ | |||
+ | Each item in the search results can be either a Product, Collection, Page, Article or Blog. You can retrieve the type of object as follows: | ||
+ | |||
+ | <pre> | ||
+ | item.object_type => 'product' | ||
+ | </pre> | ||
+ | |||
+ | The following object types are returned: | ||
+ | |||
+ | * product | ||
+ | * collection | ||
+ | * page | ||
+ | * article | ||
+ | * blog | ||
== Variables == | == Variables == |
Revision as of 16:19, 11 March 2016
This template is rendered to display the results of a search.
If you do not provide a search.liquid template in your theme, a default system template will be used instead.
<div id="searchresults"> <form action="/search" method="get"> <p> <input type="text" name="q" value="{{ search.terms | escape }}" id="q"> <input type="submit" value="Search" style="width:100px"> </p> </form>{% if search.results_count == 0 %}{% if search.terms.size > 0 %} <p>Your search for "{{ search.terms | escape }}" did not yield any results</p>{% endif %}{% else %} <ol>{% for hit in search.results %} <li> <h3>{{ hit.title | link_to: hit.url, hit.title }}</h3>{% if hit.images_count > 0 %} <div class="result-image"> {{ hit.featured_image | img_url: 'thumb' | img_tag: hit.title | link_to: hit.url, hit.title }} </div>{% endif %} <span><small>{{ hit.content | strip_html | truncate: 450 }}</small></span> <div style="clear:left"></div> </li>{% endfor %} </ol>{% endif %} <p></p> </div>
Each item in the search results can be either a Product, Collection, Page, Article or Blog. You can retrieve the type of object as follows:
item.object_type => 'product'
The following object types are returned:
- product
- collection
- page
- article
- blog
Variables
In search.liquid you have access to the following variables: