diff --git a/docs/add-ons/pro-search/tags.md b/docs/add-ons/pro-search/tags.md index fe7ca0542..ef9aaef64 100644 --- a/docs/add-ons/pro-search/tags.md +++ b/docs/add-ons/pro-search/tags.md @@ -27,57 +27,59 @@ logged in: This tag is only available if the user is logged in. Use the Form tag to create search forms. Search parameters made available by each Filter should be used as input fields (most commonly `` and ` - - - +
+ + + +
{/exp:pro_search:save} + +#### `form_attribute=` -## {exp:pro_search:url} +Specifies any html attribute you want the form to have. For example: `form_id="search"` will add `id="search"` to the form tag, while `form_class="searchform"` will add `class="searchform"` to the tag. + + {exp:pro_search:save form_id="search" form_class="searchform"} -Use this single tag to produce a search url you can use for bookmarking or quick linking. +#### `query=` -### Tag Parameters +Use this parameter to pass through a previously executed encoded search query. Not needed when [not encoding queries](https://docs.expressionengine.com/latest/add-ons/pro-search/settings.html#encode-query). + + {exp:pro_search:save query="{segment_3}"} -#### keywords -When used inside the Form or Filters tag, you can also use the shortcut syntax. Using the shortcut will inherit all the parameters set in the parent tag. You can use any of the parameters used in the Results tag. In addition to that, these parameters are available: + +## {exp:pro_search:url} + +Use this single tag to produce a search url you can use for bookmarking or quick linking. For example, this creates a URL with a query containing `keywords="foo"` {exp:pro_search:url keywords="foo"} -#### query +When used inside the Form or Filters tag, you can also use the shortcut syntax. Using the shortcut will inherit all the parameters set in the parent tag. You can use any of the parameters used in the Results tag. In addition to those parameters, these parameters are also available: + +### Parameters + +[TOC=4 hide] -The encoded search query to inherit. Not needed when not encoding queries, as this will happen automatically. Use the reset parameter to cancel this behaviour +#### `query=` - {exp:pro_search:url query="{segment_2}} +The encoded search query to inherit. Not needed when [not encoding queries](https://docs.expressionengine.com/latest/add-ons/pro-search/settings.html#encode-query), as this will happen automatically. Use the reset parameter to cancel this behaviour. -#### reset + {exp:pro_search:url query="{segment_2}"} -Set to yes to not inherit the current query. +#### `reset=` + +Set to "yes" to stop this tag from inheriting the current query. {exp:pro_search:url reset="yes"} -#### result_page +#### `result_page=` The group/template you want to link to, like in the Form tag - {exp:pro_search:url result_page="template"} + {exp:pro_search:url result_page="group/template"} -#### toggle:parameter +#### `toggle:parameter=` Toggles a single value in the given query. If the parameter value isn’t present in the current query, it generates a URL where the value is present, and vice versa. - {exp:pro_search:url toggle:parameter} + {exp:pro_search:url toggle:featured="yes"} -## {exp:pro_search:param} +NOTE: **Note:** If you simply want to add a specific value or to always override a specific value in a query, do not use this parameter. This toggle is useful when you want to more easily create a query URL for an alternative search (i.e. with vs. without a certain option). -Use this tag to output a given parameter value outside of the Form, Filters or Results tag. You can also loop through multi-valued parameters. -### Tag Parameters -#### get +## {exp:pro_search:param} -Parameter name you are targeting. **Required.** +Use this single tag to output a single given parameter value outside of the Form, Filters or Results tag. - + {exp:pro_search:param get="item_size"} + +You can also use it as a paired loop to output multi-valued parameters. + {exp:pro_search:param:loop get="category" as="cat_id" query="{segment_3}"} - {cat_id} + {cat_id} {/exp:pro_search:param:loop} -#### query +### Parameters + +#### `get=` + +Parameter name you are targeting. **Required.** + +#### `query=` + +The encoded query where the parameter is present. Required when [encoding queries](https://docs.expressionengine.com/latest/add-ons/pro-search/settings.html#encode-query). -The encoded query where the parameter is present. Required when encoding queries. +#### `as=` - {exp:pro_search:param query={segment_x}} +When outputting the values in a loop, use this parameter to set the variable name used in the loop. **Required when looping values.** -#### format +#### `format=` -Set to raw for unaltered output, set to url for url-encoded output. Defaults to html-safe output. +Set to `raw` for unaltered output, set to `url` for url-encoded output. Defaults to `html-safe` output. + + {exp:pro_search:param format="html-safe"} -Default: html-safe - {exp:pro_search:param format="raw"} ## {exp:pro_search:popular} Use this tag to display a list of popular keywords. The Search Log must be enabled for this tag to work properly. -### Tag Parameters +### Parameters -#### limit +#### `limit=` Maximum number of keywords to display. Defaults to 10. - -Default: 10 - {exp:pro_search:popular limit="10"} - {if count == 1}{/if} + {if count == 1}{/if} {/exp:pro_search:popular} -#### orderby - -Keywords are ordered by search_count in descending order by default. Set to keywords if you want to order alphabetically by keyword. +#### `orderby=` -Default: search count +Keywords are ordered by `search_count` in descending order by default. Set to `keywords` if you want to order alphabetically by keyword. - {exp:pro_search:popilar orderby="keywords"} + {exp:pro_search:popular orderby="keywords"} ### Variables -#### keywords +#### {keywords} The keywords, HTML escaped and safe to use in an EE tag parameter. - {keywords} - -#### keywords_raw +#### {keywords_raw} The keywords, as is. - {keywords_raw} - -#### keywords_url +#### {keywords_url} The keywords, URL-encoded. - {keywords_url} - -#### keywords_clean - -The keywords, cleaned by the Pro Search algorithm, ie. without punctuation or diacritics. +#### {keywords_clean} - {keywords_clean} +The keywords, cleaned by the Pro Search algorithm, i.e. without punctuation or diacritics. -#### search_count +#### {search_count} The number of times these keywords appear in the search log. - {search_count} + ## {exp:pro_search:keywords} Use this single tag to display the keywords used in a given search query. It is a shortcut for the Param tag. -### Tag Parameters +### Parameters + +#### `query=` -#### query +The encoded query where the keywords are present. Required when [encoding queries](https://docs.expressionengine.com/latest/add-ons/pro-search/settings.html#encode-query). {exp:pro_search:keywords query="{segment_3}"} + + ## {exp:pro_search:collections} Use this tag to display a list of search collections. -### Tag Parameters +### Parameters -#### collection +#### `collection=` Limit collections by names or IDs given. -#### collection_lang +#### `collection_lang=` Limit collections by their language code. - {exp:pro_search:collections collection_lang=""} + {exp:pro_search:collections collection_lang="en"} ### Variables -#### collection_id +#### {collection_id} The collection ID - {collection_id} - -#### collection_name +#### {collection_name} The collection name - {collection_name} - -#### collection_label +#### {collection_label} The collection label - {collection_label} +#### {collection_language} -#### collection_language +The collection language -The collection language. - {collection_language} ## {exp:pro_search:suggestions} -Use this tag to display a list of suggestions based on given keywords, language, and the words currently present in the lexicon. It uses either Levenshtein distance or Soundex similarity (phonetics) to determine the suggestions. Note: Using Soundex for generating suggestions is only effective for languages with a latin-based alphabet. The Levenshtein method works regardless of alphabet type. +Use this tag to display a list of suggestions based on given keywords, language, and the words currently present in the lexicon. It uses either [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance) or [Soundex similarity](http://en.wikipedia.org/wiki/Soundex) (phonetics) to determine the suggestions. -### Tag Parameters + {exp:pro_search:suggestions keywords="{pro_search_keywords}" keywords:lang="en" distance="2" limit="4"} + {if suggestion_count == 1}Did you mean{/if} + {suggestion}{if suggestion_count != total_suggestions} or {if:else}?{/if} + {if no_results}Check your spelling or try a different search term.{/if} + {/exp:pro_search:suggestions} -#### distance +### Parameters -Depending on the method used, either the maximum Levenshtein distance or maximum Soundex word length distance from the original. Either 1, 2 or 3; defaults to 2 +[TOC=4 hide] + +#### `distance=` - {exp:pro_search:suggestions distance="1"} +Depending on the method used, either the maximum Levenshtein distance or maximum Soundex word length distance from the original. Either 1, 2 or 3; defaults to 2 -#### keywords +#### `keywords=` The keywords on which to base the suggestions. Overrides any keywords given in the query. {exp:pro_search:suggestions keywords="jongle"} -#### keywords:lang +#### `keywords:lang=` The language of the keywords on which to base the suggestions. Should point to the lexicon language. Overrides the language given in the query. - {exp:pro_search:suggestions keywords:lang="en"} - -#### limit +#### `limit=` Maximum number of suggestions to return. Defaults to 5. -Default: 5 - - {exp:pro_search:suggestions limit="2"} +#### `method=` -#### method - -The method used for getting the suggestions, either levenshtein or soundex. Defaults to the former. - -Default: levenshtein +The method used for getting the suggestions, either `levenshtein` or `soundex`. Defaults to Levenshtein. {exp:pro_search:suggestions method="soundex"} + +NOTE: **Note:** Using Soundex for generating suggestions is only effective for languages with a latin-based alphabet. The Levenshtein method works regardless of alphabet type. -#### query +#### `query=` The query that contains the keywords and/or keywords:lang parameters on which to base the suggestions. - {exp:pro_search:suggestions query="your_query"} + {exp:pro_search:suggestions query="{segment_3}"} ### Variables -#### suggestion - -The suggested word in lowercase - - {suggestion} - -#### suggestion:upper +[TOC=4 hide] -The suggested word in uppercase. +#### {suggestion}, {suggestion:upper}, {suggestion:ucfirst} - {suggestion:upper} +The suggested word in lowercase, uppercase, or with only the first letter in uppercase. Because the words are stored in the lexicon in all lower case, you cannot store or retrieve suggestions in mixed case. -#### suggestion:ucfirst - -The suggested word with the first letter in uppercase. - - {suggestion:ucfirst} - -#### suggestion_count +#### {suggestion_count} The count of the current suggestion. - {suggestion_count} - -#### total_suggestions +#### {total_suggestions} The total amount of suggestions given. - {total_suggestions} - #### {if no_suggestions}{/if} Alternative syntax for the native {if no_results}{/if} conditional. - {exp:pro_search:suggestions keywords="jongle" keywords:lang="en" limit="1"} - Did you mean {suggestion}? - {if no_suggestions}No suggestions found.{/if} + Did you mean {suggestion}? + {if no_suggestions}No suggestions found.{/if} {/exp:pro_search:suggestions}