Copied to clipboard

Flag this post as spam?

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


  • Fergus Davidson 309 posts 588 karma points
    Mar 26, 2010 @ 10:48
    Fergus Davidson
    0

    XSLTSearch

    hi all,

    i am implementing  a search on a site which has a significant amount of content split over several sections:

    • products
    • information
    • literature
    • news articles
    • etc
    this is all fine, and xslt search does the job perfectly, BUT the results are unmanageable. - Because of their SEO, the client rightly have multiple references to their products in the titles and body text of the news articles and pages, and often the product searches bring a list of non-product results at the top of the list.
    There is a specific product search on the site, but owing to the site search form being on every page, users naturally use that.
    WHAT I WOULD LIKE TO DO:
    i want to split the results into tabs:
    • product
    • news
    • literature
    • other
    in an effort to push product [the goal of the site] while making users with other information requirements able to easily identify the appropriate results for them.
    Is this an easy thing to achieve in XSLTSearch? i did consider the possibility of including several XSLT searches with a variety of 'allowed' document types, then, obviously, sorting the tabs out with jquery.
    Is this the best way to accomplish this, or should i be looking at edits to the XSLT search itself to order the results and group into tabs?
    has anyone else done this? i am sure poeple have, and it would be great to know how you went about it.
    thanks

  • dandrayne 1138 posts 2262 karma points
    Mar 26, 2010 @ 11:52
    dandrayne
    0

    You'll definitely need to edito xsltsearch to do this, but it should be fairly manageable.

    Results are stored in a $matchedNodes variable, so there's nothing stopping you doing several different

    <xsl:for-each select="$matchedNodes/node [@nodeTypeAlias='Whatever']">
    ...

    To split out the results.  You'll just need to be careful about paging - removing paging and using an improbably large page size would be easiest.  Once you have the results split out you could just use any of the tab implementations out there (such as jqueryui) to make your interface

    Dan

  • Fergus Davidson 309 posts 588 karma points
    Mar 26, 2010 @ 12:20
    Fergus Davidson
    0

    thanks dan.

    i'll post an update when i am finished

  • Fergus Davidson 309 posts 588 karma points
    Mar 26, 2010 @ 15:40
    Fergus Davidson
    0

    UPDATE:

    i have tried a couple of options:

    single search

    • this followed dan's suggestion [thanks dan], but was not without issues. i got it all working [with no paging], but for some reason, the tabs were intermittently populated and also, when one of them was returned empty, one of the closing div tags was not written to the page [something i have experienced before]. 

    mulitple search

    • the 'tabs mark-up' placed in the template allowed me to drop in 3 instances of the search, picking alternate sources for the searches means that i am returning the results as they should be
    • result count is correct per tab
    • paging is correct per tab
    • mark-up is wrong as there are now duplicate 'id', but i should be able to sort that out pretty quickly
    the second was definitely easier, and unless anyone has any advice to the contrary, i would recommend this as a quick and dirty solution.
    everything seems to run reasonably quickly, though with more pages and so on, it may have performance issues.
    once the page design and search/results criteria are sorted out, i will try to see what the difference is in demand, and speed, and then may go back and try to customise the XSLTSearch to add in the tabs in a single call.

  • dandrayne 1138 posts 2262 karma points
    Mar 26, 2010 @ 15:48
    dandrayne
    0

    glad you're getting somewhere!

    regarding the empty divs, it's probably that when there are no results your div becomes self-closing (breaking css)

    <div />


    In this case you can change the output method from xml to html but this could break images

    <img src="whatever.jpg"></img>


    So you can put a non-breaking space in your div so that it doesn't close itself

    &#160;



    Hope this helps,
    Dan

  • Fergus Davidson 309 posts 588 karma points
    Mar 26, 2010 @ 17:18
    Fergus Davidson
    0

    Thanks dan

  • DrewJigsaw 12 posts 29 karma points
    Mar 30, 2010 @ 17:33
    DrewJigsaw
    0

    Hello everyone,

    I've been constructing something similar with a XSLTSearch. However I've run into a pickle and I was wondering if anyone had any ideas.

    Essentially I to am filtering search reasults by @documentTypeAlias to split out 'News' 'Articles' etc. However what I'm trying to create is checkbox list that allows users to pick which of these they would like to see at the same time. Trick is that although I can easily split matched nodes into set's for each area

    <!-- get the actual matching nodes as a nodeset -->
    <xsl:variable name="matchedNodes" select="$possibleNodes[contains($matchedNodesIdList, concat(';', concat(@id, ';')))]" />
    <xsl:variable name="articleNodes" select="$matchedNodes [@nodeTypeAlias = 'Article']"/>
    <xsl:variable name="newsItems" select="$matchedNodes [@nodeTypeAlias = 'News Article']" />
    <xsl:variable name="eventItems" select="$matchedNodes [@nodeTypeAlias = 'Event']" />
    <xsl:variable name="caseStudies" select="$matchedNodes [@nodeTypeAlias = 'CaseStudy']" />
    <xsl:variable name="reviewItems" select="$matchedNodes [@nodeTypeAlias = 'Review']" />

    I've having trouble selectively combining them. The closest I could fathum is.

    <xsl:variable name="nodesToDisplay">
    <xsl:choose>
    <xsl:when test="string(umbraco.library:RequestForm('rbFilterArticles')) = 'on'">
    <xsl:copy-of select="$matchedNodes [@nodeTypeAlias = 'Article']"/>
    </xsl:when>
    <xsl:when test="string(umbraco.library:RequestForm('rbFilterNews')) = 'on'">
    <xsl:copy-of select="$matchedNodes [@nodeTypeAlias = 'News Article']"/>
    </xsl:when>
    <xsl:when test="string(umbraco.library:RequestForm('rbFilterEvents')) = 'on'">
    <xsl:copy-of select="$matchedNodes [@nodeTypeAlias = 'Event']"/>
    </xsl:when>
    <xsl:when test="string(umbraco.library:RequestForm('rbCaseStudies')) = 'on'">
    <xsl:copy-of select="$matchedNodes [@nodeTypeAlias = 'CaseStudy']"/>
    </xsl:when>
    </xsl:choose>
    </xsl:variable>

    Unfortunately the resulting variable cannot be proccessed with xsl:for-each without producing an error.

    Any ideas would be welcome as I've had quite the head scratch today on the subject!

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 31, 2010 @ 22:15
    Chriztian Steinmeier
    0

    Hi DrewJigsaw,

    You can process the resulting variable using the node-set extension function:

    <xsl:for-each select="msxml:node-set($nodesToDisplay)/node"> ... </xsl:for-each>

    /Chriztian

     

Please Sign in or register to post replies

Write your reply to:

Draft