I installed the xslt search package and it works great.
My question: is there a way to extend the search. I created a doctype called "appartment" and there are some custom properties like number of rooms, price, surface area,...
I know I can use the searchFields parameter to search just for my custom properties but I want to make an advanced search like in google. So there should be a textfield for number of rooms, one for price,.....
Does anybody know if this is possible with the xslt search?
I've always use xsltsearch as is, without making any modifications, and from your requirement, I'd opt to use the built-in Lucene indexer to return search results as otherwise the xsltsearch would become quite complex and hard to maintain. And i'm not even sure whether xslt search would be able to handle 'and' structures, as in 'number of rooms = 2 AND price < 120'
It's quite easy to build a simple user control to hold the input values and build the search results based on the input values from the search form.
However, the latter also requires some work as you'll have to index those fields as well! Something which can be done quite easily using the event model (OOB, umbraco only indexes a few generic property fields)
I might have some examples lying around, so if you need some code, just shout.
I did it in xslt like Tim suggested and it is pretty straigtforward.
Just read the request variable in the xslt file like this: <xsl:variable name="NumberOfRooms" select="ps:uppercase(ps:getParameter(string(umbraco.library:RequestQueryString('NumberOfRooms')), '0'))"/>
Then use the variable as a filter in the possibleNodes like this: <xsl:variable name="possibleNodes" select="$items/descendant-or-self::node[ string(data [@alias='umbracoNaviHide']) != '1' and count(attribute::id)=1 and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true()) and data[@alias = 'NumberOfRooms'] = $NumberOfRooms ]"/>
and then the form:
<form name="input" action="search.aspx" method="get"> NumberOfRooms: <input type="text" name="NumberOfRooms" /> <input type="hidden" name="Search" value=" " /> // I had to add this on because otherwise you get no result at all.... <input type="submit" value="Submit" /> </form>
advanced xslt search
Hi,
I installed the xslt search package and it works great.
My question: is there a way to extend the search. I created a doctype called "appartment" and there are some custom properties like number of rooms, price, surface area,...
I know I can use the searchFields parameter to search just for my custom properties but I want to make an advanced search like in google. So there should be a textfield for number of rooms, one for price,.....
Does anybody know if this is possible with the xslt search?
Thanks Bart
Hi Bart,
I've always use xsltsearch as is, without making any modifications, and from your requirement, I'd opt to use the built-in Lucene indexer to return search results as otherwise the xsltsearch would become quite complex and hard to maintain. And i'm not even sure whether xslt search would be able to handle 'and' structures, as in 'number of rooms = 2 AND price < 120'
It's quite easy to build a simple user control to hold the input values and build the search results based on the input values from the search form.
However, the latter also requires some work as you'll have to index those fields as well! Something which can be done quite easily using the event model (OOB, umbraco only indexes a few generic property fields)
I might have some examples lying around, so if you need some code, just shout.
Cheers,
/Dirk
Comment author was deleted
Hi Bart,
That should be possible, but you'll have to do some modifications to the xsltsearch xslt file.
Thanks Dirk and Tim,
I thought it would be something like that. I wil let you know how I resolved this!
cheers
Bart
btw nice Carma, you are rated 1 and 2 :-)
Hello Dirk and Tim,
I did it in xslt like Tim suggested and it is pretty straigtforward.
Just read the request variable in the xslt file like this:
<xsl:variable name="NumberOfRooms" select="ps:uppercase(ps:getParameter(string(umbraco.library:RequestQueryString('NumberOfRooms')), '0'))"/>
Then use the variable as a filter in the possibleNodes like this:
<xsl:variable name="possibleNodes" select="$items/descendant-or-self::node[
string(data [@alias='umbracoNaviHide']) != '1'
and count(attribute::id)=1
and (umbraco.library:IsProtected(@id, @path) = false()
or umbraco.library:HasAccess(@id, @path) = true())
and data[@alias = 'NumberOfRooms'] = $NumberOfRooms
]"/>
and then the form:
<form name="input" action="search.aspx" method="get">
NumberOfRooms:
<input type="text" name="NumberOfRooms" />
<input type="hidden" name="Search" value=" " /> // I had to add this on because otherwise you get no result at all....
<input type="submit" value="Submit" />
</form>
and thats it!!!
Cheers Bart
Hi,
I am trying to create the same thing here. Did you create the form within the xslt file?
Any help would be great.
thanks
is working on a reply...