Search Results
search results
Browse
Description
Please note: This extension is no longer updated. Only use it if you are running a Symphony installation prior to 2.2. Otherwise, use the Search Index extension instead.
This Event gives a basic implementation for a generic search form.
It's features are:
- Search with multiple keywords: 'sword fish' would match entries containing 'My sword is sharp', 'my swords are sharp', 'fishing with swords is not recommended'.
- Select through which sections you want to search.
To use the search form, create a form on your website which sends a post to the page where you want you search results to be displayed. The form needs two required parameters: search[config] and search[query]:
<form method="post" action="/my-search-results-page/"> <!-- Set the configuration: --> <input type="hidden" name="search[config]" value="regular" /> <input type="text" name="search[query]" /> <input type="submit" value="Find" /> </form>
The configuration file should be located in the events directory. It's filename must be config.searchresults.[name].php. In the config-file you can provide which sections to scan:
<?php // Provide the sections to scan: This can be the handle or an ID: $sections = array('articles', 'news'); ?>
The event will return XML data similar to the following (depending on the fields of your section):
<search-results> <status message="Search completed">success</status> <query>service</query> <sections> <section id="7" handle="articles" name="Articles"> <entry id="10"> <keywords label="Keywords">services</keywords> <description label="Description">Onze diensten</description> <content label="Content"> ... some formatted HTML ... </content> <show-in-menu label="Show in menu">yes</show-in-menu> <title handle="services" label="Title">Services</title> </entry> </section> <section id="8" handle="news" name="News"> <entry id="9"> <content label="Content"> ... some formatted HTML ... </content> <date label="Date">2010-03-16T15:05:00+00:00</date> <title handle="our-new-services" label="Title">Our new services</title> </entry> </section> </sections> </search-results>
Example XSL could be:
<p>Your search <em>"<xsl:value-of select="events/search-results/query" />"</em> gave the following results:</p> <xsl:for-each select="events/search-results/sections/section"> <xsl:if test="count(entry) > 0"> <h2><xsl:value-of select="@name" /></h2> <ul> <xsl:for-each select="entry"> <li> <!-- This is just some example-code to create a link. Replace this code with the code that works for you: --> <a href="/{../@handle}/{@id}/{title/@handle}"><xsl:value-of select="title" /></a> </li> </xsl:for-each> </ul> </xsl:if> </xsl:for-each>