I just started out with Umbraco, and wanted to implement your search. I keep getting an error in the xslt though(Error parsing XSLT file: \xslt\Search.xslt), on the line <xsl:variable name="results" select="ss4u.library:SearchToXml($phrase, 0, 'RecipeSearch')" />
My search is defined in SimpleSearch4Umbraco.config as follows:
The way I understood it was that the name of this search will be 'RecipeSearch', the documenttypes to search through are 'Detail page', and the fields on those detail pages are 'Text', 'Title' and 'Ingredients'. I don't completely understand what the category is for, but as I understood it from the documentation it's for CSS.
My site is built up as follows: Doctype Homepage Doctype Search Doctype Site section Doctype Detail page
So the homepage has multiple site sections and a site section has multiple detail pages. There is 1 search page, which should show the results.
The xslt is pretty much the same as what was in the package, although I changed the sentence mentioned.
Is there anything I'm forgetting? Or do you see what I'm doing wrong?
Implementing the search
Hi,
I just started out with Umbraco, and wanted to implement your search.
I keep getting an error in the xslt though(Error parsing XSLT file: \xslt\Search.xslt), on the line <xsl:variable name="results" select="ss4u.library:SearchToXml($phrase, 0, 'RecipeSearch')" />
My search is defined in SimpleSearch4Umbraco.config as follows:
<?xml version="1.0"?>
<SimpleSearch4Umbraco xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SearchDefinition name="RecipeSearch" iterationType="IterateAll" isDefault="true">
<DocumentType alias="Detail page" category="Recipe" includeChildNodes="true" testNodeName="true">
<Property alias="Text" comparisonType="String" comparison="Contains" />
<Property alias="Title" comparisonType="String" comparison="Contains" />
<Property alias="Ingredients" comparisonType="String" comparison="Contains" />
</DocumentType>
</SearchDefinition>
</SimpleSearch4Umbraco>
The way I understood it was that the name of this search will be 'RecipeSearch', the documenttypes to search through are 'Detail page', and the fields on those detail pages are 'Text', 'Title' and 'Ingredients'.
I don't completely understand what the category is for, but as I understood it from the documentation it's for CSS.
My site is built up as follows:
Doctype Homepage
Doctype Search
Doctype Site section
Doctype Detail page
So the homepage has multiple site sections and a site section has multiple detail pages. There is 1 search page, which should show the results.
The xslt is pretty much the same as what was in the package, although I changed the sentence mentioned.
Is there anything I'm forgetting? Or do you see what I'm doing wrong?
Kind regards,
Johannes Zijlstra
Hi Johannes,
I am in stress today, will come back later this evening to you.
Cheers, Thomas
BTW: last week I noticed that there is one point missing in the documentation: You have to add the xslSearch to the config/xsltExtensions.config:
And then you get automatically in a new xslt the new header like this:
Notice the two ss4u-entries in the stylesheet attributes header
So I have to use update the documentation for this.
So please check the settings, also if the variables are set properly and it would be nice to see the complete xslt code...
Cheer, Thomas
Hello Thomas,
Thanks for your reply.
The complete XSLT is as follows:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:ss4u.library="urn:ss4u.library" xmlns:ss4u="urn:ss4u" exclude-result-prefixes="msxml umbraco.library ss4u.library ss4u"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:variable name="recSearch" select="umbraco.library:RequestQueryString('q')"/> <xsl:if test="$recSearch!= ''"> <xsl:variable name="results" select="ss4u.library:SearchToXml($recSearch, 0, 'RecipeSearch')" /> <h2>Results</h2> <p>Your search for <strong>'<xsl:value-of select="$recSearch" />'</strong> returned <strong><xsl:value-of select="count($results/SearchResult)" /></strong> items</p> <ul> <xsl:for-each select="$results/SearchResult"> <xsl:sort select="@createDate" order="descending"/> <li><a href="{@linkUrl}"><xsl:value-of select="@text" /></a></li> </xsl:for-each> </ul> </xsl:if>
I have added the xslsearch to the xsltExtensions.config as well.
Regards,
Johannes
Also, if I remove everything except the request for the querystring and just paste the value of the querystring that is correct.
The error occurs on the call to SearchToXml.
Now you have doubled the ss4u entries in the header. try this:
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:ss4u="urn:ss4u"
exclude-result-prefixes="msxml umbraco.library ss4u">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="recSearch"
select="umbraco.library:RequestQueryString('q')"/>
<xsl:if test="$recSearch!= ''">
<xsl:variable name="results" select="ss4u:SearchToXml($recSearch, 0, 'RecipeSearch')" />
<h2>Results</h2>
<p>Your search for <strong>'<xsl:value-of select="$recSearch" />'</strong> returned <strong><xsl:value-of select="count($results/SearchResult)" /></strong> items</p>
<ul>
<xsl:for-each select="$results/SearchResult">
<xsl:sort select="@createDate" order="descending"/>
<li><a href="{@linkUrl}"><xsl:value-of select="@text" /></a></li>
</xsl:for-each>
</ul>
</xsl:if>
hth, Thomas
Hello Thomas,
Sorry for the delay, couldn't get back to you before now.
With the change you suggested it works! Thanks!
Cheers!
Hi Thomas,
Does this search allow for searching for the search text on media items such as PDF files and MS office files?
thanks.
is working on a reply...