Thursday, December 19, 2013

Use the 'a=' url parameter when passing 'hidden' search strings to a SharePoint search page

On several sites we have links that trigger searches by passing the term GUID to the search page through the 'k=' parameter, as you can see from the URL. This is a neat way of showing all items tagged by a certain term. In fact you can use this method to pass any search string to a search page, not just metadata guids (example: ...resultpage.aspx?k=author:someone).







So this actually works great, but for one thing. I would like to not display the rather cryptic search string in the search box. In addition to the core search results web part on a search page the search box web part also picks up the value passed into the page by the 'k=' parameter, and displays it as the current searched for string.










One solution is to deselect the 'Display submitted search' option in the search box web part properties configuration, but I choose not to because I would like normal search strings entered in the box by the users to display.

After doing a lot of searching for alternatives one of my local MVPs, Mikael Svenson, came up with the easy solution: use the 'a=' parameter instead of 'k='. Has exactly the same effect on filtering the core search results web part, but without displaying the search string in the search box.

One important thing to note is that the core search results web part needs an additional value. Just passing in a value for the 'a=' parameter will return nothing. In my case I added a simple additional query in the 'Append text to query' field in the core results edit web part properties. I used 'IsDocument=1' because I want the search page to list all documents within the defined search scope to be listed if no other search string is given by the user.


1 comment:

  1. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!


    Melbourne SEO Services

    ReplyDelete