Skip to end of metadata
Go to start of metadata

If you need to add a search box that searches only a portion of the website, e.g. /bucs then this is how to do it.

How to set one up

In the example below, the scope parameter restricts the search. The others (collection and profile) are required for the search to work at all. The input box must be named "query".

The classes and IDs on the example form, input box and button are purely for styling and not required. There is an example of this on http://www.bath.ac.uk/learningandteaching/rdu/courses/pgskills/ in the right hand column.

The scope filters by performing a sub-string match to the document's URL. This can produce strange results if scope is not as specific as the example above. If we have this:

It will match:

To eliminate polis (and other erroneous results) we need to use something like:

Note that changing this variable does change the text on the search results page (see below).

The template output

Example search result:

http://www.bath.ac.uk/search?query=workshops&Search=&collection=website&profile=_default_preview&scope=%2Flearningandteaching%2Frdu%2Fcourses%2Fpgskills

In this section of the simple.ftl template we check if the scope parameter was passed and we tell the user that their search is restricted. This is the only difference to a normal output.