i know that XSLTSearch does a lovely job of highlighting the terms on the results page, but every now and again, when a page has a lot of text, it is nice to have this feature passed from the results page to the page which is linked from the result.
My question[s]:
would the best way to achieve this be to pass the term in the link to the page and then wash the pages content through a macro in a similar way to that which XSLTSearch does on the results page?
First, I'd modify XSLTsearch.xslt to append the search term(s) to the href of all links returned in the results of XSLTsearch.
Then I'd make a macro to display the 'bodyText' and any other fields on your template rather than using <umbraco:Item>. That macro would grab the search term(s) from the querystring and put some markup around all occurances of those terms. You could certainly take a bunch of the code from XSLTsearch.xslt to handle this. Or you could handle it as a .net macro that would probably be cleaner since XSLT is pretty terrible at string manipulation.
XSLT Search Term highlighting
hi
i know that XSLTSearch does a lovely job of highlighting the terms on the results page, but every now and again, when a page has a lot of text, it is nice to have this feature passed from the results page to the page which is linked from the result.
My question[s]:
would the best way to achieve this be to pass the term in the link to the page and then wash the pages content through a macro in a similar way to that which XSLTSearch does on the results page?
Is there a better way?
many thanks
fergus
Hi, Fergus,
I would handle it basically the way you describe.
First, I'd modify XSLTsearch.xslt to append the search term(s) to the href of all links returned in the results of XSLTsearch.
Then I'd make a macro to display the 'bodyText' and any other fields on your template rather than using <umbraco:Item>. That macro would grab the search term(s) from the querystring and put some markup around all occurances of those terms. You could certainly take a bunch of the code from XSLTsearch.xslt to handle this. Or you could handle it as a .net macro that would probably be cleaner since XSLT is pretty terrible at string manipulation.
cheers,
doug.
thanks doug.
i think for the short term i will go the xslt route, but i may go the .net route if i have any trouble with the strings.
thanks again!
just in case this is useful for anyone else, or if anyone wants to tell me that this is an absurd way to go about it, i ended up using the following:
xslt search results pass the term in the url
page then calls macro with the following xslt. c# function carries out a case-insensitive replace for the search term.
i still need to sort out the multi word search terms, but this handles the single words just fine.
any thoughts anyone?
is working on a reply...