How To... Utilise the Search Function

Pepperio provides a built in search function - make more of it...

1. The Supplied Search Code.

Below is the code provided by Pepperio to enable searching of the site. To ensure this works, the form action must direct to "/search.html" (a standard page supplied with Pepperio) and the name value of the input field must remain as 'query'.

  1. <form action="/search.html" method="post" title="search">
  2. <div id="search_form">
  3. <input type="text" name="query" id="query" />
  4. <input type="submit" value="Search" id="button" />
  5. </div>
  6. </form>

This code can be adapted to provide customisation...

2. Restricting search to a particular branch of the site

You can limit the search functionality to just one branch of the site. To do this add another hidden INPUT field to your code...

  1. <form action="/search.html" method="post" title="search">
  2. <div id="search_form">
  3. <input type="text" name="query" id="query" />
  4. <input type="hidden" name="branch" value="/news_and_events" />
  5. <input type="submit" value="Search" id="button" />
  6. </div>
  7. </form>

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' (this means that the term will be appended to the url of the destination page...

  1. <form action="/search.html" method="get" title="search">
  2. <div id="search_form">
  3. <input type="text" name="query" id="query" />
  4. <input type="submit" value="Search" id="button" />
  5. </div>
  6. </form>

Next add this code to your Search Results snippet, that displays the list of results (but remove the '*' before and after the SCRIPT tags)...

  1. <h4>You searched for the phrase "<*script type="text/javascript">
  2. var url = document.location.href;
  3. document.write(url.substring(url.lastIndexOf("=")+1));
  4. </script*>"</h4>

See Also:

Video Guides

How To...

Tag Definitions