SharePoint Search Results: Adding a link to the view properties page of a document

Posted: April 19, 2011 in SharePoint

“I found this article and one of the comments useful. So I merged and published them again.  The source link is at the end of the post.”

The out-of-the-box SharePoint search results web part doesn’t provide a way to get to the View Properties page for items in a document library. The search results provide a direct link to the document which will open a document in default editor registered within windows.
In the screen shot below notice that both the hyperlinked title (shown in the tool tip) and the url displayed both link to the actual document and not to the View Details page.

The goal is to generate a hyperlink that will allow the user to navigate to the properties display form for documents.


Clicking “View Properties” will take the user to the following page:

Step 1: Add a managed property for the integer ID of list items.

In order for the solution to work properly we must first create a Metadata Property Mapping for the ID of list items. SharePoint out-of-the-box does not include these identifiers in its search index.
Open the SSP
Click Search Administration
Under Queries and Results, click Metadata properties.
Click Crawled Properties:


Search for ows_id. Then edit the crawled property.


Select the checkbox at the bottom of the page to include the property in the search index:


Return to the Metadata Property Mappings screen by clicking on Metadata properties on the left side of the page.
Click New Managed Property and set the values as follows:

  • Property Name: ListItemID
  • Description: Numeric identifier of SharePoint List Items (i.e. documents, pictures, and custom lists).
  • Type: Integer
  • Add ows_id as a crawled property.

Run a full crawl of the content source

Step 2: Add the Metadata property to the search results web part

Now that the metadata property has been added to SharePoint we now need to make the property available to the search results web part. In my example I’ve added the search and search results web parts to a web part page but the same steps apply if you are editing the search results web part in the search center.
Open your search results page in edit mode.
Locate the search results web part and click Modify Shared Web Part


In the Results Query Options section, open the editor for the Selected Columns property:

Add a reference to the ListItemId property as follows:

 <Column Name="ListItemID" />

At this point the custom Metadata property we created will now be retrieved with every search query. The value will come back in the xml returned by the query servers and is just begging to be displayed somewhere on the page.

Step 3: Modify the XSL to display the hyperlink to the View Properties page.

The next step it to create a hyperlink to the View Properties page using not only the custom ListItemId Metadata property but also several other properties already available to us: url, sitename, and contentclass.

  1. Click the XSL Editor button in the web part properties panel.
  2. Copy the contents of the editor and paste into an XSL editor like Visual Studio .NET or any text editor.
  3. Near the bottom of the XSL file paste in the following template definition just prior to the </xsl:stylesheet>tag:

<xsl:template name="DisplayViewPropertiesLink">
 <xsl:param name="itemUrl" />
 <xsl:param name="siteUrl" />
 <xsl:param name="listItemId" />
 <xsl:param name="contentclass" />
<!-- you may have issues with case, the doc lib will not matche by the substring functions, so do a translation -->
 <xsl:variable name="itemUrlLower" select="translate($itemUrl, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
 <xsl:variable name="siteUrlLower" select="translate($siteUrl, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
 <xsl:if test="$contentclass='STS_ListItem_DocumentLibrary'">
 <xsl:variable name="docLibLoc" select="substring-before(substring-after($itemUrlLower, concat($siteUrlLower, '/')), '/')" />
 <xsl:variable name="viewPropUrl" select="concat($siteUrl, '/', $docLibLoc, '/Forms/DispForm.aspx?id=', $listItemId)" />
 <xsl:text disable-output-escaping="yes">&amp;nbsp;-&amp;nbsp;</xsl:text><a href="{$viewPropUrl}">View Properties</a>
 </xsl:if>
 </xsl:template>

  1. This template first checks to see if the item is part of a document library. If so, it parses out the document library name and then builds up a URL pointing to the View Properties page and outputs a hyperlink to the page.Important note: This link is hard-coded to point to the out-of-the-box View Properties page. If document libraries have custom View Properties pages, this solution will need to be modified.
  2. The last step is to include a call to the new StyleSheet template. In my example, I’ve placed the call just after the rendering of the modified date:
    
    
<xsl:call-template name="DisplayString">
 <xsl:with-param name="str" select="write" />
</xsl:call-template></span>

<xsl:call-template name="DisplayViewPropertiesLink">
  <xsl:with-param name="itemUrl" select="url" />
  <xsl:with-param name="siteUrl" select="sitename" />
  <xsl:with-param name="listItemId" select="listitemid" />
  <xsl:with-param name="contentclass" select="contentclass" />
</xsl:call-template>

<xsl:call-template name="DisplayCollapsingStatusLink">

Step 4: Deploy and test

Now that the XSL StyleSheet has been modified the last step is to copy the XSL back into the web part property and save your changes. Submit a simple search for documents and verify the View Properties link appears after the date.

Special thanks to Doug Perkes  for providing this solution, and Trevor for his comment.

Advertisements
Comments
  1. Jeremy says:

    The call to the new template seems to break the web part. Once that is added I get the “Unable to display this web part” error. Have you run into this problem?

  2. Habel says:

    great content….

  3. satyam says:

    thanks for gr8 post
    Have you try with document library with folder? it don’t show correct URL when any item selected from document library folder

    • Navid.R says:

      I think you should maybe create a new variable in the step 3.

      • Jonathan says:

        Hi !
        Great post, but real problems on library with folders. Navid talks about a new variable, ok, but from what ? I don’t find any search variable which help me to know if there is folder or not.
        Any idea about that ?
        Thanks.

  4. Jurgen says:

    Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to more added agreeable from
    you! By the way, how can we communicate?

  5. Hi there, this weekend is pleasant in support of me, as this point in time i am reading this impressive informative post
    here at my house.

  6. Don’t bother seeking to kill Crushcog, but battle the excess enemies that spawn together with him.
    In addition, Tycoon also acts just as one Auction House Addon, by scanning the auction house and hinting exactly what is most beneficial at the time.
    Add from the fact that being a druid you need to the ability to buff your stats
    and vomit a damage shield, and you’re basically an unstoppable killing machine.

  7. I need to to thank you for this great read!! I definitely enjoyed every little
    bit of it. I have you bookmarked to look at new things you post…

  8. e hookah says:

    Very good blog! Do you have any hints for aspiring
    writers? I’m planning to start my own site soon but I’m
    a little lost on everything. Would you suggest starting with a free platform like WordPress or go for
    a paid option? There are so many choices out there that I’m completely overwhelmed ..
    Any ideas? Thanks!

  9. Charline says:

    First, from your caring and gracious attitude with
    them and the relationship you have built. The Council
    in Brigantine will now consist of 3 Democrats and 3 Republicans with
    a Republican Mayor Philip Guenther. One of the catchiest tunes from Kern’s 1927 musical Show Boat is Life Upon the Wicked Stage.

  10. I do not drop a ton of responses, however i did a few searching and wound up here SharePoint Search Results: Adding a link to the view properties page
    of a document | SNR SharePoint Blog. And I do have a few questions
    for you if it’s allright. Could it be simply me or does
    it give the impression like some of these remarks
    come across like coming from brain dead people?
    😛 And, if you are writing on other sites, I’d like to keep up
    with everything new you have to post. Would you list of every one of
    all your community pages like your linkedin profile, Facebook page or
    twitter feed?

  11. Whole grain breads, cereals and pastas have high amounts of thiamin. “Methylcobalamin is required for the function of the folate-dependent enzyme, methionine synthase. In a 2006 research study, it was discovered that reading and math skills were a stumbling block to deciphering the confusing labels on many foods.

  12. Nothing comes du doan bong da y hom nay of the rules.
    Are those games where the club, to blame the pitch,
    They knew they’d be caught at the far post and goes wide.

  13. Even though you might disgust relocation and varying to firmly other places, but sometimes,
    you only can. In this Cosby Sweater Project, each episode offers different kinds of game
    to recreate his magic loud shirts. If you join him, one of the advantages that you’ll have
    is being able to understand they psychology behind marketing.

  14. rstrui.exe says:

    Hi! This is my first visit to your blog! We are a collection of volunteers and
    starting a new project in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a extraordinary job!

  15. WMVCore.dll says:

    There’s certainly a lot to know about this topic.
    I love all of the points you made.

  16. I usually do not comment, but after browsing through a
    few of the comments here SharePoint Search Results:
    Adding a link to the view properties page of a document
    | SNR SharePoint Blog. I do have 2 questions for you if it’s allright.
    Is it only me or does it give the impression like some of the comments appear like they are coming
    from brain dead visitors? 😛 And, if you are posting on additional online social sites, I’d like to keep
    up with everything fresh you have to post. Would you make a list of
    the complete urls of all your shared sites like your twitter feed, Facebook page or linkedin profile?

  17. Its such as you read my thoughts! You appear to understand a lot about this, such as you wrote the e book in it or something.
    I believe that you simply can do with some % to drive the message house
    a bit, however instead of that, this is wonderful blog.
    A fantastic read. I’ll certainly be back.

  18. My brother suggested I may like this website.

    He was once entirely right. This put up actually made my
    day. You can not consider just how so much time I had
    spent for this information! Thank you!

  19. This article will assist the internet viewers for creating new weblog or even a blog from
    start to end.

  20. Thanks for the auspicious writeup. It actually used to be a leisure account it.
    Glance advanced to more introduced agreeable from you!
    By the way, how can we keep in touch?

  21. Great post. I was checking constantly this blog and
    I am impressed! Extremely useful information specially the last part :
    ) I care for such info much. I was seeking this particular
    information for a long time. Thank you and good luck.

  22. Abliazov says:

    This design is spectacular! You certainly know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to
    start my own blog (well, almost…HaHa!) Excellent job.
    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  23. It’s a shame you don’t have a donate button! I’d certainly donate to this brilliant blog!

    I suppose for now i’ll settle for bookmarking and adding
    your RSS feed to my Google account. I look forward to fresh updates and will talk about
    this website with my Facebook group. Talk soon!

  24. Heya! I’m at work browsing your blog from my
    new iphone 3gs! Just wanted to say I love reading your blog and look
    forward to all your posts! Carry on the fantastic work!

  25. it says:

    Wonderful beat ! I wish to apprentice at the same time
    as you amend your web site, how could i subscribe for a blog site?
    The account aided me a acceptable deal. I have been tiny bit acquainted of this your broadcast
    offered vivid transparent idea

  26. The Arm Heater easily connects to the accessory plug on the heating element.

    ” A second astrological chart is computed for the time of your soul’s incarnation, eighty-eight days before your birth. With the advent of post style outdoor heaters, there has been a quest on the part of almost all manufacturers to make the cheapest heaters in order to capture the largest possible share of the patio heating marketplace.

  27. Kristina says:

    If you would like to grow your knowledge simply keep visiting this
    web site and be updated with the most up-to-date information posted here.

  28. Harley says:

    Wonderful article! We will be linking to this particularly great content on our site.
    Keep up the good writing.

  29. Do you have a spam problem on this site; I also am a
    blogger, and I was curious about your situation; many of us have created some nice procedures and we are
    looking to trade solutions with others, why not shoot me an email if
    interested.

  30. Hi, this weekend is pleasant designed for me, because
    this occasion i am reading this enormous educational article here at my house.

  31. It’s going to be great to see Assassin’s Creed return to a
    completely land-based game. Is it a compelling part of the game for
    every player to partake in. This will be the first Assassin’s Creed installment without a competitive multiplayer mode since Assassin’s Creed II.

  32. Hello everyone, it’s my first pay a quick visit at this web site, and paragraph is in fact fruitful in support of me, keep up posting these content.

  33. System kontroli wycieku wody Posejdon służy do wczesnego wykrywania
    i lokalizacji nieszczelności w systemie domów, mieszkań i instalacji przemysłowych.

    System blokuje przepływ wody, aby wyeliminować przyczyny
    nieszczelności i informuje o tym wypadku.

  34. However, unlike HSC Chemistry, Physics is less experience-based, as there are
    less things upon which we need to refer
    to repeatedly throughout the course. It consists of an easy
    to understand material and is according to exam needs. Simply put, we can say that
    if you have decided to study for GRE exams of you own it
    is a good decision and you can achieve your goal provided you
    start preparing for it at right time and in a well-planned way.

  35. Appreciating the persistence you put into your blog
    and in depth information you offer. It’s awesome to come across a blog every once in a while that isn’t the same unwanted rehashed material.
    Wonderful read! I’ve bookmarked your site and I’m including your RSS feeds
    to my Google account.

  36. pdf says:

    Appreciating the time and effort you put into your site and in depth
    information you offer. It’s great to come across a blog every once in a while that isn’t the same
    outdated rehashed material. Wonderful read! I’ve saved your site and I’m including your RSS feeds to my Google account.

  37. video games says:

    Up for a second year running, teleporting, etc. Unfortunately I still enjoy it more properly.

    Speaking of which way to market online and sit infront of computer
    games have levels wherein tasks become tougher as players of free gaming.

  38. I don’t know if it’s just me or if everyone else experiencing problems with your site.
    It looks like some of the text in your content are running off
    the screen. Can somebody else please comment and let me
    know if this is happening to them too? This might be
    a issue with my browser because I’ve had this happen before.
    Many thanks

  39. autoresponder program says:

    Hello mates, how is all, and what you wish for to
    say regarding this paragraph, in my view its truly remarkable for me.

  40. Hi there friends, its impressive piece of
    writing concerning cultureand fully explained, keep it up all the
    time.

  41. You have to gather as much information as you can to ensure you are on the
    right track. Therefore, skin around your eyes need extra special care.
    Eliminate any product that does not offer a money back guarantee.

  42. Weight Loss says:

    After eating so much of this, your body cannot keep up with the removal process and the fat begins to build, clogging arteries and causing organs tto malfunction. Older birthday celebrants enjoy a irthday that’s full
    of memories, fun, and laughter. “Clinical observations and analysis’ have shown the important role played by the GH system in the development, maintenance, and repair of the skin. When it comes to ways to get fit and reach your goals, the only limit is your imagination. It satisfies my family’s sweet tooth and is really good for you.

  43. certainly like your website but you need to test the spelling on several of your posts.

    Several of them are rife with spelling problems and I find
    it very troublesome to inform the truth
    then again I’ll surely come again again.

  44. I’m not that much of a online reader to be honest but your blogs really nice, keep it up!

    I’ll go ahead and bookmark your website to come
    back later on. Many thanks

  45. As with a traditional membership site, customers get a new shipment of the gooods each month
    until they decide tto cancel. You marry him for love and you two work to take care each other and establish a happy family.
    All of the meals are designed by doctors and delivered by e – Diets.
    I really feel like I missed out a lot inn my adult years.
    Wii Sports and Fit games aree fuun ways for teens tto get their families
    and friends involved with fitness activitikes as well.

  46. gradon says:

    What’s up, after reading this awesome piece of writing i am too cheerful to share my know-how here with mates.

  47. Hello there! Do you know if they make any plugins to assist
    with Search Engine Optimization? I’m trying to get my blog to
    rank for some targeted keywords but I’m not seeing very good results.
    If you know of any please share. Many thanks!

  48. Hi, yeah this paragraph is truly pleasant and I have learned lot of things from it on the topic of blogging.
    thanks.

  49. Я обожаю эти цвета! this image является, фактически, лучшим фото!Хорошая глубина 😀 Просто красивое фото
    с очень хорошим светом 😀 Превосходные
    фото захватывают дух. Ваши фото выглядят фантастически!!!

  50. I’m gone to inform my little brother, that he should also pay a
    quick visit this web site on regular basis to take updated from hottest news update.

  51. Hello! I know this is kind of off topic but I was wondering if you knew where I could locate
    a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble
    finding one? Thanks a lot!

  52. wonderful put up, very informative. I wonder why the opposite experts of this sector do
    not realize this. You should proceed your writing.
    I’m confident, you’ve a huge readers’ base already!

  53. After going over a number of the articles on your web site,
    I truly like your way of writing a blog. I saved it to my bookmark site
    list and will be checking back soon. Please visit my web site too and tell me what you think.

  54. Nice post. I learn something totally new and challenging on sites I
    stumbleupon every day. It will always be interesting to read through content from other authors
    and practice something from their websites.

  55. hi!,I really like your writing veery a lot! percentage we keep up a
    correspondence more approximately your article on AOL?
    I need a specialist on this area to solve my problem. May be that
    is you! Having a look ahead too peer you.

  56. And it is a fact that outdoor toys and play equipment like these
    offer the best fun for children. All sitemaps figure every different page so you can support
    manufacturing. This helps with bringing in more revenue
    and creating loyal customers.

  57. staracki dom says:

    Family members may have various reasons why they need to put
    their loved one in a nursing home, for instance continuous incontinence, due to a medical condition, and some elderly
    patients might have terminal illnesses or memory illnesses for instance dementia and Alzheimer’s.
    Your nursing resume needs to have professionalism in it as well as excellent skills and ability to work under pressure.
    A medical sonographer has to keep his knowledge and expertise abreast
    with the current developments in the medical field.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s