Guides
Tutorials
Pop Tags

Search

Webpop indexes all your content with a powerful search engine. The search engine can be used directly through PopTag templates or to make complex queries from extensions.

To do a search and show the results in a template, you use the <pop:search> tag. Here’s a simple example of searching any content containing the word “test” using the query attribute and displaying a paginated list of results with links.

<pop:search query="test" per_page="10">
 
<pop:results wrap="ul" break="li">
   
<h2><a href="<pop:permalink/>"><pop:title/></a></h2>
   
<pop:description format="html"/>
 
</pop:results>
 
<pop:pagination/>
</pop:search>

By default <pop:search> will only search for content with a permalink. That means content with no template associated won't show up in your search results. To search all your content, use:

<pop:search all="true">

The per_page attribute and <pop:pagination> work exactly the same for both <pop:paginate> and <pop:search> If no query attribute is specified, <pop:search> will look for a q parameter in the query string of the current url. If that parameter is present it will be used as the query. If not, <pop:search> will display nothing (and trigger a <pop:no_search> if followed by one). You can use <pop:query> inside <pop:search> to display the query being used.

The last point means that it is very easy to setup a search form. If you have a section called Search with the id search and a search.tpl template assigned, then anywhere where you want a search box, you can do something like this:

<pop:content from="search">
  <form action="
<pop:permalink/>">
   
<label>Search <input type="search" name="q"/></label>
   
<button>Go</button>
 
</form>
</pop:content>

And in search.tpl:

<pop:search per_page="10">
 
<h1>Searching for <strong><pop:query/></strong></h1>
 
<pop:results wrap="ul" break="li">
   
<h2><a href="<pop:permalink/>"><pop:title/></a></h2>
   
<pop:description format="html"/>
 
</pop:results>
 
<pop:pagination/>
</pop:search>

You can limit the search to a specific section by using the in attribute. The following will only return search results from the blog:

<pop:search in="blog">

You can also force the search to only return entries, categories or sections by using the type attribute. For instance the following example will only return entries.

<pop:search type="entry">
Continue to Extensions Overview »