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:
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]
[/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.
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]
[/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
Nice mod!
cheers,
doug.
is working on a reply...