Author:
TwistedInteractive
Version:
0.4
Released:
2 September 2010
Category:
Events

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>

Repository

http://github.com/TwistedInteractive/Search-Results

Discuss this Extension

Compatibility

2.7.10 Unsure
2.7.9 Unsure
2.7.8 Unsure
2.7.7 Unsure
2.7.6 Unsure
2.7.5 Unsure
2.7.4 Unsure
2.7.3 Unsure
2.7.2 Unsure
2.7.1 Unsure
2.7.0 Unsure
2.6.11 Unsure
2.6.10 Unsure
2.6.9 Unsure
2.6.8 Unsure
2.6.7 Unsure
2.6.6 Unsure
2.6.5 Unsure
2.6.4 Unsure
2.5.4 Unsure

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details