How To... Display the Search Results
Paginate the results list and display the search term
1. Use the supplied Search page.
Pepperio includes a Search page that your search form should reference (normally 4th item from bottom).
On this page build a LIST, but with this list use '_search' as the 'src' attribute and add a new attribute called 'queryfield' with a value of 'query' (the value of the input field from the Search form). It also uses an ordered list to number the result items that are returned.
%LIST(
type=ol,
src=_search,
queryfield=query,
itemtemplate=search_results_listitem)%
2. Paginating the list.
You can paginate the results of a search query so that you limit the amount of results displayed on a page, and provide links to pages that hold the rest of the results. To do this, adapt your search LIST by adding a 'usepaginator' attribute, an id for the list, and limiting the number of items to display by using the 'maxitems' value...
%LIST(
type=ol,
src=_search,
queryfield=query,
itemtemplate=search_results_listitem,
usepaginator=yes,
id=list1,
maxitems=10)%%PAGINATOR(
type=ul,
listid=list1,
itemtemplate=paginatorlink,
activetemplate=paginatoractive,
previoustemplate=paginatorprevious,
nexttemplate=paginatornext,
noresultstemplate=paginatornoresults,
hasresultstemplate=paginatorhasresults)%
The below the list, within the snippet, add a PAGINATOR tag. This tag will render a list of links, so first declare the type of list you want it to be. Next add a 'listid' value that corresponds to the id of the search list. After the itemtemplate the rest of the attributes are specific to the Paginator, and full definitions of each can be found under the Paginator tag.
3. Displaying the search term on the results page
Adding a small amount of javascript, enables the search term to be written to the page, but first to make this work, change the method of the form from 'post' to 'get' (see: Utilising the Search Function).
Next add this code to your Search Results snippet, that displays the list of results (but remove the '*' before and after the SCRIPT tags)...
<h4>You searched for the phrase "<*script type="text/javascript">
var url = document.location.href;
document.write(url.substring(url.lastIndexOf("=")+1));</script*>"</h4>
%LIST(
type=ol,
src=_search,
queryfield=query,
itemtemplate=search_results_listitem)%