Pro version users can setup location and content categorization. To provide the user with control over which categories to search add DIVs with ID's sew_locationChooserControl and/or sew_contentChooserControl. At runtime these will hold location radio button controls and content checkbox controls, be default.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="Keyoti_SearchEngine_Web_Common/SearchUnit.css" rel="stylesheet" />
<script src="Keyoti_SearchEngine_Web_Common/SearchUnit.js"></script>
</head>
<body>
<div id="sew_searchBoxControl"></div>
<div id="sew_locationChooserControl"></div>
<div id="sew_contentChooserControl"></div>
<div id="sew_searchResultControl"></div>
</body>
</html>
By default, when the user changes a selection the results will automatically update (a new search is initiated to do this). This may not be ideal user experience if searches are slower than a second or two (due to large index or busy server), or if it is preferable to let the user update all of their choices before refreshing the results. To use a button to update results use the following code:
...
<script type="text/javascript">
keyotiSearch.updateOnOptionChange = false;
</script>
...
<input type="button" onclick="keyotiSearch.showPage(1, true)" value="Update results" />
To set the location or content category to search within, call the code below. Note that it works with or without the sew_locationChooserControl or sew_contentChooserControl DIVs on the page.
...
<script type="text/javascript">
keyotiCategoryChoosers.setSelectedLocation("locationName"); //set the default location to search inside
keyotiCategoryChoosers.setSelectedContents(["contentName1", "contentName2"]); //set the default contents to search inside
</script>
...
For example, to use a SELECT control in the location chooser;
...
<span id="sew_locationChooserControl">
<select id="sew_locationOptionTEMPLATE" class="sew_locationOption">
<option class="sew_locationOptionItem" value="${Value}">${Value}</option>
</select>
</span>
...
The dynamic elements are: ${Value} (the location name text) and ${Id} which is a unique integer for the location option.
In the above example, the template is defined in a SELECT element. The templating engine will put location items inside the SELECT as OPTION elements - in other words, the content of the SELECT element is repeated for each location item.
Remember that the search engine can only search one location category at a time (it can search multiple content categories), therefore it could be confusing to the user if the control used allows multiple selections.
The default templates for location and content choosers are;
...
<div id="sew_locationChooserControl">
<div id="sew_locationOptionTEMPLATE" class="sew_locationOption">
<label>
<input type="radio" name="sew_locationOption" class="sew_locationOptionItem" value="${Value}"/>${Value}
</label>
</div>
</div>
<div id="sew_contentChooserControl">
<div id="sew_contentOptionTEMPLATE" class="sew_contentOption">
<label>
<input type="checkbox" class="sew_contentOptionItem" value="${Value}"/>${Value}
</label>
</div>
</div>
...
By default the category name as contained in the index (backend) is displayed to the user (frontend), but it is possible to modify that. To do that override keyotiCategoryChoosers.convertLocationBackendNameToFrontEndName and/or keyotiCategoryChoosers.convertContentBackendNameToFrontEndName.
For example there is a default location named "All", to change it to "Everything" use;
...
keyotiCategoryChoosers.convertLocationBackendNameToFrontEndName = function (locationName, convertBack) {
if (!convertBack) {
if (locationName == "All") return "Everything";
} else {
if (locationName == "Everything") return "All";
}
return locationName;
}
...
The 'convertBack' parameter indicates that the reverse conversion is required.
Similarly to convert a content category named "Forum" to "ABC".
...
keyotiCategoryChoosers.convertContentBackendNameToFrontEndName = function (contentName, convertBack) {
if (!convertBack) {
if (contentName == "Forum") return "ABC";
} else {
if (contentName == "ABC") return "Forum";
}
return contentName;
}
...