Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bart de Jonge 29 posts 51 karma points
    Jul 07, 2009 @ 13:56
    Bart de Jonge
    0

    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

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 07, 2009 @ 14:15
    Dirk De Grave
    0

    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

    Jul 07, 2009 @ 14:19

    Hi Bart,

    That should be possible, but you'll have to do some modifications to the xsltsearch xslt file.

     

     

  • Bart de Jonge 29 posts 51 karma points
    Jul 07, 2009 @ 14:42
    Bart de Jonge
    0

    Thanks Dirk and Tim,

    I thought it would be something like that. I wil let you know how I resolved this!

    cheers
    Bart

  • Bart de Jonge 29 posts 51 karma points
    Jul 07, 2009 @ 14:43
    Bart de Jonge
    0

    btw nice Carma, you are rated 1 and 2 :-)

  • Bart de Jonge 29 posts 51 karma points
    Jul 07, 2009 @ 17:34
    Bart de Jonge
    1

    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

     

  • Jake 23 posts 53 karma points
    Oct 16, 2009 @ 12:16
    Jake
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft