View
Articles in this section describe how to add a search input and display search results to your website.
Search-Input
The search input can be placed like so:
<div class="search-input-wrapper"> <h3>People can search here:</h3> <?php $searchHtml->input() ?> </div>
The method takes the parameter groupKey which will filter out search entries with only that group.
Search-Results
To display found Search-Entries, you define a result area with SearchHtmlBuilder::resultOpen() and SearchHtmlBuilder::resultClose(). Inbetween SearchHtmlBuilder::resultContent() must be called and at that point, search results will be displayed. SearchHtmlBuilder::resultHeader() can be called to display number of results and a button to close the results.
<?php $searchHtml->resultOpen(null, 'div', array(), '#employees', 'No Employees Found') ?> <?php $searchHtml->resultHeader() ?> <?php $searchHtml->resultContent() ?> <?php $searchHtml->resultClose() ?>
For flexibility you can set the number of results and button to close manually using the methods SearchHtmlBuilder::resultCloseButton() and SearchHtmlBuilder::resultNum().
<?php $searchHtml->resultOpen(null, 'div', array(), '#employees', 'No Employees Found') ?> <div class="result-header"> <?php $searchHtml->resultNum ?> <?php $searchHtml->resultCloseButton() ?> </div> <?php $searchHtml->resultContent() ?> <?php $searchHtml->resultClose() ?>
The second parameter, in this case div, is the HTML-Elements Type, so you can choose what type of HTML-Elment you want to have as a search-result wrapper.
With the forth parameter you can hand javascript a jquery selector of items that you want to hide when found Search-Entries are shown.
The last parameter is the fallback-string, it is shown when no search-results where found.