Search

Bind A Query

A search form only affects a query loop when the query asks for that search.

Use search on the query tag:

phpresources/views/front-page.php
{{ search }}  <input type="search" placeholder="Search">  <button>Search</button>{{ /search }}{{ query:posts search }}  <h2><a href="{{ url }}">{{ title }}</a></h2>{{ /query:posts }}

If the search box is empty, the query still works as a normal query.

Use a name when the page has a specific search for a specific list:

php
{{ search name="projects" param="keyword" in="title" }}  <input type="search" placeholder="Search projects">  <button>Search</button>{{ /search }}{{ query:project search="projects" }}  <h2><a href="{{ url }}">{{ title }}</a></h2>{{ /query:project }}

The query uses the form named projects, reads the keyword parameter, and searches project titles.

With Other Query Options#

Search can sit beside normal query options:

php
{{ query:project search="projects" sort="title:asc" }}

The search narrows the query. The other options still decide what kind of content is queried and how it is ordered.

Use a {{ sort }} control inside the matching search form when the reader should choose the order from the page. See Search Sorting.