Adding a search page

This uses the integrated WebHare search engine called ‘Consilio’.

Create the folder pages/search/.

Add to this folder the file search.siteprl.xml with the following content:

<siteprofile xmlns="">
<filetype namespace="" kind="virtualfile" title="Search page">
<dynamicexecution webpageobjectname="search.whlib#SearchPage" />
<robots xmlns="" noindex="true" nofollow="true"/>

<!-- Consilio catalog, name MUST start with <modulename>:
Change for your own site the folder attribute in the contentsource (site::<your-site-name>)
<index xmlns="" name="examples:examplesite">
<contentsource type="publisher:webhare" folder="site::example-site" />

Add file search.whlib to the folder with the following content:

LOADLIB "wh::witty.whlib";
LOADLIB "mod::consilio/lib/api.whlib";
LOADLIB "mod::publisher/lib/webdesign.whlib";
LOADLIB "mod::system/lib/webserver.whlib";

UPDATE PUBLIC MACRO PrepareForRendering(OBJECT webcontext)
INSERT "searchpage" INTO webcontext->htmlclasses AT END;

STRING words := GetWebVariable("words");
RECORD results := RunConsilioSearch("modulename:websitename", CQParseUserQuery(words), [ summary_length := 150 ]);

EmbedWittyComponent( this->pagefolder || "search.witty:search", CELL[...results, words] );


Next add the file search.witty to the folder with the following content:

[component search]
<form action="./" method="get">
<input type="search" value="[words]" name="words" placeholder="Search for..." />
<button type="submit">Search</button>

<div class="results">
[if totalcount]
[totalcount] item(s) found for '[words]'.
[elseif words]
No items found for '[words]'.
No search term given

[if results]
<ul class="searchresults">
[forevery results]
<a href="[objectid]">
<b class="title">[if title][title][else]<i>No title</i>[/if]</b>
[if summary]
<span class="summary">[summary]</span>


To make the consilio-search engine to create summaries of just the content of a page, add html comments, in the main witty template around the [contents] macro else the summary will also contain the navigation and footer content.


Add to the main siteprofile ( <webdesignname>.siteprl.xml ) directly after the existing applysiteprofile rule(s):

<applysiteprofile path="pages/search/search.siteprl.xml" />

Finally, create in the website a new file of type ‘Search page’. The filetype will not be visible immediately, you’ll need to enable “Show all types’. In this case that’s probably okay as you don’t need site users to be able to create multiple search pages. But if you want to enable users to select the Search page type, add the following code to the site profilel:

<to type="all" />
<allowfiletype typedef="" />

For styling add ‘search.css’ (or .scss) to the folder and add to main scss file definition (<webdesignname>.scss )

@import "./pages/search/search.css";

and put your styling for the search page in the search.css file.