Monday, October 17, 2011

Return to the context of the contextual search

The contextual search is integrated in the standard search center of SharePoint 2010. So we have one search experience, that can be modified.
The scope of the contextual search is added to the search query url by the parameters cs (contextual scope: This Site/This List) and u (url of the site/list).


The masterpage of the search center doesn't provide any navigation. And other portals are not part of the navigation within the Home site. But it would be nice to be able to go back to where we started the search, no matter where we came from. This can be done with some simple Html and javascript.
Add a HTML Form Web Part to the left zone of the search results page and paste the following code into the source editor:


<br/>&#160;&#160;&#160;<a href="/"><img class="ms-rtePosition-4" alt="Go Home" src="/_layouts/images/hhome.png" border="0"/></a>&#160;<font color="#0072bc"><a href="/">Go Home</a>&#160; </font><a href="#" onClick="javascript:window.location.replace(GetUrlKeyValue('u'));"><img class="ms-rtePosition-4" alt="Go Back" src="/_layouts/images/back.gif" border="0"/></a>&#160;<a href="#" onClick="javascript:window.location.replace(GetUrlKeyValue('u'));">Go Back</a><br/><br/>

This results in two options: go home, or go back to the context.
When there is no context, you will return to the default page of the search center.


No comments:

Post a Comment