Liquid Template Variables - search: Difference between revisions
From Spiffy Stores Knowledge Base
Created page with "The Liquid template variable '''search''' has the following attributes: == <code>search.performed</code> == == <code>search.results</code> == == <code>search.results_count<..." |
mNo edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
== <code>search.performed</code> == | == <code>search.performed</code> == | ||
Returns ''true'' if a successful search was performed. | |||
== <code>search.results</code> == | == <code>search.results</code> == | ||
Returns an array of search results. The search items may be a | |||
* [[Liquid Template Variables - product|product]] | |||
* [[Liquid Template Variables - collection|collection]] | |||
* [[Liquid Template Variables - article|article]] | |||
* [[Liquid Template Variables - blog|blog]] | |||
* [[Liquid Template Variables - page|page]] | |||
In addition to the standard attributes returned by the respective variables, an additional attribute ''object_type'' is supported to distiguish each of the search results. | |||
== <code>search.results_count</code> == | == <code>search.results_count</code> == | ||
Returns the number of results found. | |||
== <code>search.terms</code> == | == <code>search.terms</code> == | ||
Returns the original string that was submitted for the search. | |||
The ''highlight'' filter can be used to apply a different style to any instances in the search results that match up with ''search.terms''. | |||
<pre> | |||
{{ item.content | highlight: search.terms }} | |||
</pre> | |||
== Further Reference == | |||
* [[Liquid Basics]] | |||
* [[Liquid Tag Reference]] | |||
* [[Liquid Filter Reference]] | |||
* [[Liquid Variable Reference]] | |||
* [[Liquid Paginate Tag|Pagination ]] | |||
Latest revision as of 13:24, 25 June 2018
The Liquid template variable search has the following attributes:
search.performed
Returns true if a successful search was performed.
search.results
Returns an array of search results. The search items may be a
In addition to the standard attributes returned by the respective variables, an additional attribute object_type is supported to distiguish each of the search results.
search.results_count
Returns the number of results found.
search.terms
Returns the original string that was submitted for the search.
The highlight filter can be used to apply a different style to any instances in the search results that match up with search.terms.
{{ item.content | highlight: search.terms }}