Adding an Edit Document Link to Enterprise Search Results
Posted
Monday, October 27, 2008 5:18 PM
by
CoreyRoth
I have seen a lot of requests to get more functionality on search results for documents lately. People want to be able to edit documents, go to the folder the document is in, go to the site, view properties, etc. I have solutions for all of those which I will be sharing in the next few days. However, I wanted to share this one first, because it is easy to implement and does not require any custom code. The goal is to get a link that will allow you to edit the document (instead of opening it in read only mode) directly from your search results.
As you will see the solution is actually quite simple. Start by editing your results.aspx page and then edit the CoreResultsWebPart. I have chosen to put my Edit Document link on the line following the title of the document. In the Data View Properties of the web part, click XSL Editor. Scroll down and look for the span with a class of srch-Title and insert the following block of code after the closing span and before the srch-Description.
<div class="srch-Description">
<a href="{$url}" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.3','0
','SharePoint.OpenDocuments','','','','1','0','0','0x7fffffffffffffff')">Edit Document</a>
</div>
Save the XSL and click Apply. You should now see an Edit Document link in your search results similar to the one below.
Clicking on the Edit Document link will present the user with the Read Only / Edit menu just like they get when they are opening the document from a document library.
How did I figure this magic out? It really was pretty simple, I just looked at a document library page and figured out what script method was being called. If you spent money on a high dollar product just to get this feature, I am sorry. Also remember that the Edit Document functionality only works in Internet Explorer. Try it out and see if it works for you. For other document functions such as Go to Folder, View Properties, and View Version History, take a look at my Document Link Handler for Enterprise Search.