Texpattern context demo

Current global context
SectionArticle
context_demo137

Search context

Search context is created when a site visitor enters a search term in a Txp search_input form. We could call it a functional context, i.e., a context for responding to user input.

By default, the search_input form returns the user to the default section. You can specify a section, which you need to do if you want to restrict the search results to articles from that section. You might also want to do this for purely presentational reasons, to use a different page template for search results.

search_input sets only the global search context: where the search form sends the user (the section attribute), and whether the search is for an exact match, for all terms in the query but in any order, or for any term in the query (the match attribute). You can filter the search results further by setting attributes in the article tag displayed in the search context itself (i.e., on the search results page).

The code below shows how to configure the search_input form to send the user to the current section’s landing page. By default the search is for an exact match. Try a search to see how article and Txp’s search result tags respond to search context.

This code:

<txp:search_input section='<txp:section />' label="" button="Search" />

produces this output: