<txp:search_input /> single tag, 6 attributes

search_input

The search_input tag is a single tag. This tag will provide a text entry field for search parameters and an optional button to initiate the search.

attributes

section="unset" 
  • Use the specified section as the destination page that will display the search results.
html_id="unset" 
  • The HTML id attribute assigned to the search form.
button="unset" 
  • Creates and labels a button to initiate the search.
size="15" 
  • Sets the size of the text field.
form="search_input" 
  • Use specified form. (Yes, a TXP-form to build a customized X/HTML form.)
match="exact" 
  • Values
    • exact : search terms must exactly match the words in the article in the order given. This mode is also automatically selected if the search term is surrounded with double quotes
    • any : any of the search terms in an article will cause it to show up in the results
    • all : all of the search terms in the article must exist (in any order) for the article to be included in the results

presentation

label="Search" 
  • Label prepended to item (or as first list item, where appropriate).
  • if wraptag is available and is set to ol or ul, the label will be the first list item.
wraptag="p" 
  • (X)HTML tag (without brackets) to wrap around the list.
class="search_input" 
  • (X)HTML class attribute to apply to the wraptag.

genealogy

Version 4.3.0

  • match attribute added

Version 4.0.7

  • html_id attribute added.
<txp:search_input /> 2 examples

Display a search input form

<txp:search_input label="Search" button="Search" size="20" wraptag="div" />

Elements required for building a customized (X)HTML search form

You can build your own custom search form (in a TXP form, like you do with e.g. the article tag) by specifying form=“txpformname” inside the <txp:search_input /> tag.

The following is the content of txpformname and shall depict the absolute minimum of tags and attributes required:

<form action="<txp:site_url />">
<input type="text" name="q" />
</form>

If you use a customized TXP form, Textpattern doesn’t automatically wrap the (X)HTML form output with form tags, so you need a pair of those to enclose your code. The name=“q” attribute/value pair inside the text input tag is required for even initiating a search query.

Textpattern, as of this writing, will use a user defined form named search_results, or an internally defined default form if no search result form is defined by you.

Other tags used: site_url