• Sample Extension: Search

This how - to is primarily for  Administrators on sites

The system can be configured so that either all or part of the site can be searched using keywords.  This help system uses this system.  It handles characters from any language (i.e., all of UTF-8).  Any word which appears on more than half the pages will be ignored.  Pages which display additional information when a visitor "logs in" will show what is displayed before a visitor logs in (for example, restricted categories will not be displayed on a category list).

Steps:

  • Decide which sections are to be searched, by default all non-hidden content pages, unhidden and unrestricted categories and unhidden products under at least one unhidden and unrestricted category will be searched.  Note: only paged generated by the site will be indexed. 
  • Request search be activated for the site (the site is examined each night for changes). 
  • Create a "Search Results" page with the tag |.linkins:utfsearch.|.  Save the page and note its page ID.  For the purpose of this we will assume its 1003.
  • Create a search form and place it somewhere, normally this will be on the content and/or catalog page template.
    |.f:form method="post" action="/cgi-bin/complex2/showPage.plx?pid=1003".|
    |.f:input type='text' name='words' value="|.passBack:__searchWords.|".|
    ... optional bits ...
    |.f:input type='submit' value='Search'.|
    |.f:/form.|

Changing the default behavior:  these all go where "optional bits" is shown above.

  • The default is to display the page title followed by an abstract from the page (normally the meta-description if one is supplied).   To just display the page title use
    |.f:input type='hidden' name='__searchFormat' value='short'.|
  • The default is to search the entire visible site.  To restrict it to certain sections (e.g., the Complex Help and Categories) use the following:
    |.f:input type='hidden' name='searchSectionList' value="190 - ComplexHelp:category".|
  • There is a built in template which displays the available pages at the top and bottom of the results. A line with "Documents 1 - 9 of 22 matches." followed by the search results. It uses the following styles: .searchPageLine, .SearchNumberLine and .searchScore.    Below is an example
    .searchPageLine a { border: 4px  #81773F solid; padding: 0px 3px; border-radius: 2em; text-decoration: none;
         color: white; background:  #81773F; font-weight: bolder;}
     .searchPageLine b { border: 4px  #41370a solid; padding: 0px 3px; border-radius: 2em;
         font-weight: bold; font-size: 1em; margin: 5px 0px; color: white; background: #41370a;}
     .searchPageLine { padding: 5px 0px; }
     .SearchNumberLine {font-size: 0.9em; font-family: Arial,sans;}
     .searchScore { color:#81773F; font-weight: bold;}

.