Copied to clipboard

Flag this post as spam?

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


  • David Conlisk 432 posts 1008 karma points
    Mar 27, 2009 @ 16:15
    David Conlisk
    0

    Modified XSLT Search: search only selected areas of your site

    My client requested that the site search behaviour be changed slightly. The site has a search control on each page. When you enter a search term and click the button, you get taken to the search results page. This shows you the search results from the entire site, but it also shows a number of checkboxes (all ticked by default). Each checkbox corresponds to a top-level area of the site (just below the home page node, each node gets a checkbox on the search page). The user can then refine the search by checking/unchecking boxes to only search particular areas of the site.

    I used tkahn's post here as a guide when making the changes:

    http://forum.umbraco.org/yafpostst5950Modified-XSLT-Search-search-only-a-certain-doctype.aspx

    I won't post the full xslt file here, but here are the parts that I changed.

    I use a querystring parameter called selectedAreas, which is a comma-separated list of node ids:
    [code]

    [/code]

    I updated the xsl:choose statement which determined from the querystring parameters what search was happening - I added a clause to check for the selectedAreas parameter in the url:

    [code]


    [/code]

    And here is the updated code to output the checkboxes with the search box. 1080 is the id of my homepage (could make this a parameter of course rather than hardcoding it!), so a checkbox is created for each Section node below the home page:

    [code]







    sections found


     


    [/code]

    And that's it! If you can't follow this (I've only included the updates after all) then please get in touch and I can give you the full xslt template.

    Hope that helps!

    David

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Mar 27, 2009 @ 16:49
    Douglas Robar
    0

    Nice mod!

    cheers,
    doug.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies