6.2 Search Results (Advanced) Template
In order for the CMS to process search queries and search result, a Content Item must be created that is assigned a Search template, typically called "HTML-Search.tpl.php". This Search template must either contain the Simple or Advanced snippets to display results.
Advanced Method
The Advanced Search Results Template provides you with an AJAX based filter. This allows the site user to look for results in just HTML, Document or News Content Types.
First, your template must contain the following Javascript:
<script type="text/javascript">
var searchContentType = "document";
var searchCategories = "";
function createXMLHttpRequest() {
if (window.ActiveXObject) {
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
var xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}
function refreshListing(page) {
var xmlHttp = createXMLHttpRequest();
if (page==undefined) {
page = 1;
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
document.getElementById("search_results_inner").innerHTML = xmlHttp.responseText;
}
}
};
var url = "templates/<?php echo $template_path;?>/includes/search/listings.inc.php?searchterm=<?php echo urlencode($_GET['searchterm']);?>&search_contenttype=" + searchContentType + "&categories=" + searchCategories + "&page=" + page;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function refreshContentTypes() {
var xmlHttp = createXMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
document.getElementById("search_result_tabs").innerHTML = xmlHttp.responseText;
}
}
};
var url = "templates/<?php echo $template_path;?>/includes/search/contenttype_tabs.inc.php?searchterm=<?php echo urlencode($_GET['searchterm']);?>&search_contenttype=" + searchContentType + "&categories=" + searchCategories;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
</script>
Where you want the search results to appear, you must then use:
<?php
include "templateincludes/search/search_content.inc.php";
?>
Top of Page