Keyword Search

"It's still web development, it's just way easier!"

The matchrating function uses keywords and evaluates how well they match against a set of values. This example uses the Pages database, but it could instead use a any other database or even a list of values. The test excludes any pages that don't have a "1" as its Aux value, which is one way to let it know which pages to include.

Example

Search Form

<form action="/search.wrival">
<input type="text" name="keywords" value="<#keywords>">
<input type="submit" value="Search">
</form>

Results Page (/search.wrival)

<#results = "
	<ol>
	<#Pages:
		test='<#Pages|<#each>|Aux> == 1',
		matchrating='<#keywords>',
		keys,
		each='
		<li>
			<a href=<#dq><#each><#dq>><#Pages|<#each>|Title></a><br>
			<#Pages|<#each>|Description>
			<br><br>
		</li>
		'
	>
	</ol>
":hide>

<#truecount == 0 ? 
	'Sorry, no results were found.' ! 
	'<#truecount> Page<#truecount != 1 ? "s"> Found:'
>

<#results>