MOSS – Open search results for editing (Office 2003/7)

I visited a customer which wanted the option to directly open a document from the search results for editing (in default when you click a document from the search results it opens as read-only). I found this blog article which describes how to do it by embedding some JavaScript into the search results XSL, I did exactly as described and it didn’t work, I realized that this happens because this customer uses Office 2003. I had to do some digging using the IE developer toolbar (soon to be an integral part of IE8) on the “Edit with Microsoft Word” context menu item, which brought me to the conclusion to use other JavaScript functions to open files as described bellow:

<div class="srch-Description">
    <a href="{$url}" onclick="return editDocumentWithProgID2('{$url}','','SharePoint.OpenDocuments')">Edit Document</a>
</div>

To use this, edit you results XSL, insert this code before the srch-Description span (in the “main body template” area – this span appears few more times in the XSL).

After adding it your search result should look like this:
 image

 

 

 

 

 

 

 

 

 

 

This code was tested and working both with Office 2003 and Office 2007.

I did some more editing on the XSL in order to display the “Edit Document” link only for office documents.

The version which supports 2003 documents (.doc, .xls, .ppt)

<xsl:if test="substring($url,string-length(normalize-space($url))-3,4) = '.doc'>
or substring($url,string-length(normalize-space($url))-3,4) = '.xls'
or substring($url,string-length(normalize-space($url))-3,4) = '.ppt'"
 
<div class="srch-Description">
        <a href="{$url}" onclick="return editDocumentWithProgID2('{$url}','','SharePoint.OpenDocuments')">Edit Document</a>
    </div>
</xsl:if>

The version which supports 2003 & 2007 documents (.doc, .xls, .ppt, .docx, .xlsx, .pptx)

<xsl:if test="substring($url,string-length(normalize-space($url))-3,4) = '.doc'>
or substring($url,string-length(normalize-space($url))-3,4) = '.xls'
or substring($url,string-length(normalize-space($url))-3,4) = '.ppt'
or substring($url,string-length(normalize-space($url))-4,5) = '.docx'
or substring($url,string-length(normalize-space($url))-4,5) = '.pptx'
or substring($url,string-length(normalize-space($url))-4,5) = '.xlsx'"
 
<div class="srch-Description">
        <a href="{$url}" onclick="return editDocumentWithProgID2('{$url}','','SharePoint.OpenDocuments')">Edit Document</a>
    </div>
</xsl:if>

David Birin

發佈了75 篇原創文章 · 獲贊 5 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章