|
The TnR Global Esearch compoment uses Smarty to process the templates that display the search form and query results.
Smarty Template Syntax Reference Search Form:
Special Variables for Search Form: $formHead- Top of query form $search - query value from last query cycle $formEnd - Bottom of query form Form Variables: search - query value for search count - number of results per page Sample form: <div class="componentheading"> Enterprise Search </div> {$formHead} Query action: <input name=search size=40 value="{$search}"><select name=count><option>10 <option>25 <option>50 </select><input type=submit value="Search"> {$formEnd} <p> Query Results: The Query results template has two sections: Header and single result - the single result part is duplicated by being contained in a Smarty foreach loop. Special Variables for Search Form: Header Variables: $pageUrl - link to fetch a different search results page "{$pageUrl}0" - First page "{$pageUrl}{$previousPage}" - Previous page "{$pageUrl}{$nextPage}" - Next page $stats - Stats array (keyed) - see example of how to display and varies between search services Repeating Section Variables: $results - keyed array containing results of a query Each entries is structured, with the structure being search service specific. Some fields are: $entry.TITLE - Results entry Title $entry.URL - URL to fetch result entry $entry.CACHEDPAGE - URL to cached page (optional) $enry.snippet - text clause found for entry $entry.UPDATED - date of entry Sample Results Template: <table><tr><td width=60><a href="{$pageUrl}0">First</a><td width=60><a href="{$pageUrl}{$previousPage}">Previous</a><td width=60><a href="{$pageUrl}{$nextPage}">Next</a></tr></table> Stats: {foreach from=$stats key=k item=v} {$k} = {$v}<br> {/foreach} <hr><table border=1 cellspacing=2> {foreach from=$results key=k item=anItem} <tr><td rowspan=2 bgcolor="{cycle values="#ffffff,#ffccff"}">{$k+$page+1} <td bgcolor="#99ffff"><a href="{$anItem.URL}" target=_blank>{$anItem.TITLE}</a> ........ [<a href="{$anItem.CACHEDPAGE}" target=_blank>Cached page</a>] .... {$anItem.UPDATED} <tr><td> {$anItem.snippet}<br><!-- <hr> {foreach from=$anItem key=k item=v} {$k} = {$v}<br> {/foreach} --> {/foreach} </table><hr><table><tr><td width=60><a href="{$pageUrl}0">First</a><td width=60><a href="{$pageUrl}{$previousPage}">Previous</a><td width=60><a href="{$pageUrl}{$nextPage}">Next</a></tr></table> |