Yahoo! Search

Introduction

Yahoosearch is a plugin for simply search content from your website. This plugin is based on the Yahoo! BOSS service platform.

YahooSearch is

This plugin is a very easy way to search a website including files like pdf's.

YahooSearch is not

YahooSearch is not a search which you can customize. It just searches through your website without sorting the results in for example langagues. It's just possible to sort the results in filetypes in the advance search.
If you are looking for a more flexible plugin, look for the other search plugins.

Collection Config

To use the yahoosearch plugin, you have to put it into the CollectionConfig in .configxml (or .configxml.children) in the appropriate collection in the data/ directory. For example:

<?xml version="1.0"?>

<bxcms xmlns="http://bitflux.org/config">
<plugins> 
    <parameter name="xslt" type="pipeline" value="yahoosearch.xsl"/>  
    <extension type="html"/> 
        <plugin type="yahoosearch"> 
            <!-- <parameter name="testSite" value="www.liip.ch"/>  --> 
            <parameter name="BOSSAppID" value="sdofhafhusfÜEdsggfdskmgDV"/> 
        </plugin> 
</plugins> 
</bxcms>

Parameters:

  • testSite: If you develop locally, the BOSS service won't find your website. For testing reasons it's possible to search in an online Website. If your develop online, just let this parameter commented.

Search Form

It's easy to include a form in your website. See this example:

<form style="display:inline;" name="search" id="search" action="/search/" method="get">
    <input type="text" name="query"/>
    <input title="searchbutton" name="Suche">Search</input>
</form>

Be shure the landing page of this form is where your plugin is located.

XSLT

See this example:

<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:xhtml="http://www.w3.org/1999/xhtml"  
xmlns="http://www.w3.org/1999/xhtml"  
xmlns:ys="http://www.inktomi.com/" 
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" 
xmlns:php="http://php.net/xsl" 
exclude-result-prefixes="xhtml forms php i18n" 
>  
  
<xsl:import href="master.xsl"/>  
<xsl:import href="../standard/common.xsl"/>  
<xsl:output encoding="utf-8" method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>  
<xsl:variable name="query" select="php:functionString('bx_helpers_globals::GET','query')" /> 
<xsl:variable name="type" select="php:functionString('bx_helpers_globals::GET','type')" /> 
<xsl:variable name="advanced" select="php:functionString('bx_helpers_globals::GET','advanced')" /> 


  
<xsl:template name="content">  
     
    <h1><i18n:text>suche</i18n:text> </h1>  
     <form style="display:inline;" name="search" id="search" action="{$collectionUri}" method="get"> 
    <input type="text" class="searchinputfield" name="query" id="q" > 
        <xsl:attribute name="value"><xsl:value-of select="$query"/></xsl:attribute> 
        </input> 
    &#160; 
    <xsl:choose>
    	<xsl:when test="$advanced=''">
    
    <a href="{$collectionUri}?advanced=true">erweiterte Suche</a>
    
    </xsl:when>
    <xsl:otherwise>
    <input type='hidden' name='advanced' value='true'/>
    
    	 Types: 
    <select name="type" size="1">
    
      <option >all</option>
      <xsl:choose>
	      <xsl:when test="$type='html'">
		<option selected="true">html</option>
	      </xsl:when>
	      <xsl:otherwise>
		    <option>html</option>
	      </xsl:otherwise>
      </xsl:choose>
            <xsl:choose>
	      <xsl:when test="$type='pdf'">
		<option selected="true">pdf</option>
	      </xsl:when>
	      <xsl:otherwise>
		    <option>pdf</option>
	      </xsl:otherwise>
      </xsl:choose>
    </select>
    
    </xsl:otherwise>
    </xsl:choose>
 
     <input type='submit'  value="abfrage abschicken"/>    
    </form><br/><br/>
    
    
    
    <xsl:if test="/bx/plugin/ys:ysearchresponse/ys:resultset_web"> 
    <h2><i18n:text>suchresultate</i18n:text>: <xsl:value-of select="$query"/></h2>  
    </xsl:if> 
 
    <xsl:apply-templates select="/bx/plugin/ys:ysearchresponse/ys:resultset_web" />  
 
</xsl:template> 
  
 
<xsl:template match="ys:resultset_web"> 
    <i18n:text>suchresultat</i18n:text> 
    <xsl:text> </xsl:text>  
    <xsl:value-of select="@start"/> - <xsl:value-of select="@start + @count"/>  
    <xsl:text> </xsl:text><i18n:text>von</i18n:text> <xsl:text> </xsl:text><xsl:value-of select="@totalhits"/> 
      
    <xsl:if test="(@start - @count+1) > 0"> 
     <a> 
        <xsl:attribute name="href"><xsl:value-of select="$collectionUri"/><xsl:value-of select="@start - @count"/>/?query=<xsl:value-of select="$query"/></xsl:attribute> 
    &lt;&lt; 
    </a>  
        <xsl:text>  -  </xsl:text>  
    </xsl:if> 
    <xsl:if test="@totalhits >= (@start + @count) "> 
        <a> 
    <xsl:attribute name="href"><xsl:value-of select="$collectionUri"/><xsl:value-of select="@start + @count"/>/?query=<xsl:value-of select="$query"/></xsl:attribute> 
    >> 
    </a> 
    </xsl:if> 
    <hr/>
     
    <xsl:apply-templates select="ys:result"/> 
</xsl:template> 
     
    
<xsl:template match="ys:result"> 
     
    <a> 
    <xsl:attribute name="href"> <xsl:value-of select="ys:url" /></xsl:attribute> 
    <xsl:value-of select="ys:title" disable-output-escaping="yes" /> 
    </a> 
    <xsl:if test="contains(ys:url,'.pdf')"><b> (pdf) </b></xsl:if> 
 
    <br/> 
    <xsl:value-of select="ys:abstract" disable-output-escaping="yes"/> 
 
    <hr/> 
</xsl:template> 
     
</xsl:stylesheet>

Links

For more Informations about BOSS:
http://developer.yahoo.com/search/boss/

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
These projects are supported by Liip AG