webDAV and SharePoint: Customising the search results

If you are using Enterprise Search for a network location accessible through webDAV, you will find that clicking on search results will try to open the results in Internet Explorer. Here is a quick method to add an option for users to open links as Web Folders.

NOTE1: This only works in Internet Explorer 5 or above.
NOTE2: You will need SharePoint Designer for this tutorial.
NOTE3: You must have a knowledge of html (understand tags, elements and attributes).

  1. Launch SharePoint Designer and open your SharePoint site. Find your results.aspx page from your search centre, and make a copy of it. Let’s call this file docresults.aspx in our example.
  2. Now edit the new file you created, called docresults.aspx. Looking at the code, you must add the following line under <style type="text/css">:
    a {behavior: url(#default#AnchorClick);}
  3. Save the file, and exit Web SharePoint Designer.
  4. If you created a custom search results page, you must now follow steps 5 to 7 in order to configure your site to use the appropriate results page. Otherwise jump to step 8.
  5. Navigate to your portal as a SharePoint administrator. Click on Site Actions menu and select Site Settings.
  6. Under Site Collection Administration, click on the Search scopes option.
  7. For each scope you want to use the custom search results page, you must change is settings and specify the file name of the target results page you want to use (e.g.: docresults.aspx).
  8. Now do a search (any search) on your site using a scope that would return results using the custom page.
  9. On the results page, click on Site Actions menu and select Edit Page.
  10. Locate your Search Core Results Web Part (should be on the Bottom Zone by default) and click on the edit menu. Choose Modify Shared Web Part.
  11. Now, under the Search Core Results edit panel you should find a section called Data View Properties. Under this section, click on XSL Editor… button.
  12. You can now see the code used for returning search results. What we need to look for here is the cold responsible for each result returned. Look for <xsl:template match="Result">
    You can see under this tag that each search result comprises of some span tags. Let’s have a look at three particular ones:

    • srch-Icon: The icon representing the application used to open the object returned
    • srch-Title: The title of the object returned in the search result
    • srch-URL: The URL of the object returned

    We are paying attention to these three span tags because they are clickable http links. You can see that each of these spans have a <a> (anchor) element, which contains a href="{$url}" attribute. If you want to make one of these links open the file in webDAV mode, all that you need to to is add the following extra attribute into the anchor of each span:


Alternatively, you could add an extra span containing a link to open in webDAV mode. Here is a snip of code which you could include just after the closing of the src-title span tag:

<span><a href="{$url}" folder="{url}" id="{concat(’CSR_IMG_’,$id)}" title="Click here to open the target folder in webDAV mode using Windows Explorer.">[Open in WebDAV]</a></span>
  • Click on Save to close the Web Part text editor. Click OK on the Search Core Results edit panel. Finally, click on Exit Edit Mode (just under the Site Actions menu) to finish.
  • That’s all! Hope you find this useful! For more information about the behaviour of webDAV folders in Internet Explorer, refer to this MSDN article.

    Tags: ,

    Leave a comment

    Blog Categories

    Recent Posts