Further work on fixing a colleague’s code. Like some of the posts I’ve found, he seems to have thought that to get the query string parameter he’d have to use Javascript – something like this. However, I found myself thinking of the Data View web part – it allows parameters based on the query string. Most people know about that. What I found, and what I think some folks don’t realise, is that the Search Core Results Web Part allows you to have query string parameters too…
Don’t believe me? Open SharePoint Designer, and go to the properties of the Search Core Results Web Part:
Look – it has parameters:
And you can see these in the code – in just the same structure as the Dataview WebPart:
Then you can use the query string value (which I’ve called query) like so:
<xsl:value-of select="&query" />
And I’ll explain why I’ve been going through all this in my next post…
[…] search term. Doing this requires knowing your file extension (so you only process PDFs this way), knowing the query string parameter for what is being searched for, and that you can pass parameters into Acrobat Reader. I’m not […]
Hi Andy,
What exactly are the steps to be able to grab the Querystring from the Search Results webpart? I’ve tried editing the results.aspx page of my SearchCenter from Sharepoint Designer and it directs me to the _catalogsmasterpagesearchresults.aspx file.
Is this the correct file to edit to be able to add the parameters? I tried adding a parameter from that page and it just resets to an empty Parameters list. What gives?
Thanks in advance and hope you can provide help as I need to implement your PDF highlighting solution.
Hi Raymond,
Ah, right. That’s happening ‘cos your page is attached to a page layout. Various options. The easiest is:
– Go to Search Center > Pages.
– Create a new ‘Page’. Give it a title, and choose a page layout of ‘(Welcome Page) Search Results Page’
– Open SharePoint Designer. Browser to your Search Center > Pages library.
– Right click on your new page
– Select ‘Detach from Page Layout’
– Now double click on it to open it for editting.
You’ll now be editting your own stand-alone copy of the page, rather than the page layout.
Of course, you could detach the results.aspx page itself, but I like to leave the out-of-box pages there.
How do I use this to dynamically change the CSS class being applied?
Thanks.