Thursday, May 14, 2015

Introduction to SharePoint 2013 Display Templates

Copyright from: MATTHEW MCDERMOTT'S BLOG

SharePoint 2013 introduces a new technique for presenting search results: Display Templates. If you have worked in previous versions of SharePoint and had to modify the look and feel of Search Results you know how cumbersome it is. In 2013 the new rendering techniques have several distinct advantages.
  • Display templates are HTML and JavaScript rather than XSL
  • Display templates are configured for the Site and Site Collection rather than for a Web part
  • Display templates are applied with rules and logic
  • Display templates are applied to individual result items, not the entire result set
  • Display Templates are used for Results of all kinds, search results, content by search results, and refiners
  • …and the list goes on
In this post I’ll show you the basics of creating a Display Template and then future posts will focus on the cool stuff you can do once you know these basics. I will assume that you are using a Search Site Collection. If you aren’t then you will have to tailor your changes accordingly. I also assume that you know how to deal with Crawled and Managed Properties. I have written about this for 2010 and it’s not too terribly different in 2013, in fact you can do it from the Site Collection now!

The Business

You have to have a reason to change the look of your results. In my case I have added a property to the User Profile called Twitter User Name. This way, users can opt in to showing off their social connection to Twitter. The HR department wants to increase social engagement in the company so they have asked my SharePoint team (me) to add the Twitter link to their People Search result. They would like it to link to the users Twitter profile page. So here we go:
060413_2337_Introductio1.png

The Basics

  1. From the Search Center navigate to Site Settings. In the Look and Feel section chose Design Manager.
  2. In Design Manager choose Upload Design Files.
  3. Click the link at the top of the page to open the Master Page Gallery in Windows Explorer.060413_2337_Introductio2.png
  4. Browse down the folder structure to Display Templates/Search/ and locate the Item_Person.html file. This is the file used for the out of the box People Search result. Notice that there are actually two files named Item_Person. We always work with the HTML file leaving SharePoint to manage the JavaScript file.060413_2337_Introductio3.png
  5. Copy the Person_Item file to your desktop and rename it to Item_Twitter_Person (this way when we copy it back it won’t overwrite the original file.)
  6. Now open the file in a text editor and find the title tag. Change the title to Twitter People Item.060413_2337_Introductio4.png
  7. In the next section are a bunch of tags that begin with . These control the metadata for the Display Template. The one we’re interested in is the ManagedPropertyMapping tag. We need to add any new custom properties to this tag before we can display that property in the page. This is where you have to decide what Managed Properties from the Search Service you are going to use in your page. In my case the fine IT folks told me it was called TwitterAccountName. So I’ll add that to the end of the line. Pay attention to the syntax here. (In a later post I’ll discuss more about the syntax of this declaration. For now just duplicate the field name.)060413_2337_Introductio5.png
  8. Now we need to add the field to the display part of the page. If I were to create a link to Twitter for my own account it would look like this: Twitter:   What I need to do is swap out my account with a token that will be replaced by the user in the search results. Microsoft introduced a new token that we will use for this purpose _#= to start and =#_ to end. That combination of characters will tell SharePoint to look at what’s in between and treat it like JavaScript. So what we need now is a way to reference our field TwitterAccountName. We do that by referencing the Context of the Current Item in the search results. All put together it looks like this: _#= ctx.CurrentItem.TwitterAccountName =#_. So now our code looks like this inserted below the NameValue div:060413_2337_Introductio6.png
  9. Save the file and copy it back to the server by dragging it back to the Search Display Templates folder where you started. If you refresh the Explorer windows you will notice that SharePoint automatically created a matching .js file.060413_2337_Introductio7.png
  10. Now we need to tell SharePoint when to use our new Display Template. We do this with a Result Type. Return to Site Settings and choose Search Result Types from the Site Collection Administration section.
  11. Locate the Person result type, hover click and choose Copy.060413_2337_Introductio8.png
  12. Change the name to Twitter Person and change the Action | What should these results look like? toTwitter People Item. Notice how the Display Template URL changes to the JavaScript sister file SharePoint created.060413_2337_Introductio9.png
  13. Click Save and return to the Search Center to check your work.
  14. Execute a search on the People Search vertical and you should see the results of your work.060413_2337_Introductio10.png
  15. So we achieved our goal, but there’s something I don’t like about the result. Oso does not have a Twitter account, so we should not show the “Twitter:” text. This is a simple change and demonstrates the last basic concept for the article.
  16. You can open and edit the Display Template right our of the Explorer window. Then each time you save the file it will update on the server immediately. So, go ahead, open the file in your text editor right out of SharePoint.060413_2337_Introductio11.png
  17. Now that you have the file open we need to add some conditional code so we only write the Twitter tag if the user entered a value. This is super easy. The trick is to tell SharePoint that it is a code block. For that I’ll use an HTML comment and our special tag again. This is what our code looks like now. I added my JavaScript in between the comments and wrapped it around my divs.060413_2337_Introductio12.png
  18. Return to the Search Center and test the search. You should see that the values only display when they are not blank.060413_2337_Introductio13.png

Conclusion

So what have we learned?
  • You can use a text editor to create Display Templates from copies of the out of the box files.
  • You can embed and emit custom managed properties in your search results.
  • You can run JavaScript in your Display Template for conditional formatting.
Please remember that Display Templates, like other assets in the Master Page Gallery, must be Published in order for everyone to see them. Once you have completed your edits, return to the Mater Page Gallery and Publish and Approve the files so that your users will be able to see them.
What’s Next? Well, I think I am going to show you once and for all how to display the SharePoint presence icon and hover card in search results….next time!

Wednesday, May 13, 2015

SharePoint 2010 - Drives are running out of free space.

Copyright from: blah.winsmarts.com

As this post on blogs.msdn.com details out, this is due to a health analyzer rule configured in SharePoint. While that blogpost does a great job explaining why this monitoring is necessary, how you can tweak it, it still becomes a nuisance on SharePoint virtual machines used for development.
It also becomes a nuisance on production environments because SharePoint databases are set to auto grow. In other words, as the database is being used, it only grows, and grows, and GROWS!
Seriously, how many of you have put in work to compact the database on a regular basis? Those of you who answered no, you’re sitting on  a time bomb. Shame on you!

Anyway, compacting databases isn’t something you do blindly. This is a science on it’s own, and how and when you compact the database depends on the usage and purpose of the database. Usually this is a consideration for production environments.
In this blogpost, I am not going to go in depth in all that. This blog post is about development virtual machines that are starved on disk space, and this ever growing database issue, makes it worse. So here is how you can give yourself the gift of extra disk space on your dev. vm.
Step #1: Do the usual stuff first, delete files you don’t need. Running the Disk Cleanup Tool is a good start.
Step #2: Go to central admin, and decrease the # of days to store the log files.
  • In central admin, go to monitoring
  • Go to reporting\Configure diagnostic logging.
  • In the Trace Log section, in the Number of days to store log files box, type in a smaller number – I usually am happy with the last 20 mins of logs or so :)
  • Go to 14\Logs and delete all the files in there. Don’t delete the “LOGS” directory.
Step #3: All those managed services that the farm wizard created – well they use disk space, in the form of databases generally. Not just disk space, they also take CPU cycles. Delete the services you are not using.
Step #4: Compact databases, login to SQL Server management studio with a user that has sysadmin rights, and run the following script -
  1: DECLARE @DB VARCHAR(255)
  2: DECLARE C CURSOR FOR
  3: SELECT NAME FROM SYS.DATABASES WHERE IS_READ_ONLY=0 AND STATE=0
  4:   AND NAME NOT IN ('master','model','tempdb','msdb')
  5: OPEN C
  6: FETCH C INTO @DB
  7: WHILE @@FETCH_STATUS=0
  8: BEGIN
  9:   EXEC SP_DBOPTION @DB,'trunc. log on chkpt.','true' 
 10:   DBCC SHRINKDATABASE (@DB)
 11:   FETCH NEXT FROM C INTO @DB
 12: END
 13: CLOSE C
 14: DEALLOCATE C
Enjoy all that extra disk space.

Understanding how search results are displayed in SharePoint Server 2013

Copyright from: tothesharepoint

This is a blog post in the series "How to change the way search results are displayed in SharePoint Server 2013 and SharePoint Online."

For an overview of the blog post in this series, go to How to change the way search results are displayed in SharePoint Server 2013.
In this blog post, we’ll learn: 

How search results are displayed by default
When you search for something in a Search Center, your results are displayed differently. For example, in the screenshot below, notice how the icons for Word, PDF, and Excel are displayed for each results. 
Default display of search results
By hovering over the first result, more information about the search result is displayed.

Default PPT hover panel
By hovering over the fourth result, the information that is displayed is different from what you saw when you hovered over the first result.
Default PDF hover panel
What’s going on here, and what’s making the search results display so differently? Well, that’s what I’ll explain in this blog post.


About controlling how search results are displayed

Search results are displayed in a Search Results Web Part. The following screenshot shows how SharePoint uses two display templates to control how information about search results should be displayed:
  1. Item display template - used to control how you want information in the body of the Search Results Web Part to be displayed.
  2. Hover display template - used to control how you want information in the hover panel to be displayed.
Display templates used to display search results

There are 90 default search display templates available. This might seem like a lot, but I’ll explain why there are so many later. To see all the default search display templates, go to Site settings --> Master pages and page layouts. In the Master Page Gallery, click Display Templates --> Search.
When you go to this folder, you’ll see that there’s an HTML file, and a JavaScript file for each display template.
Display templates in Search folder 
To view or edit a display template, use the HTML file. SharePoint automatically transforms the HTML file into an associated JavaScript file when you upload it. Because the two files are associated, any changes you make to the HTML file will be automatically updated in the associated JavaScript file.

I’ll explain how display templates work in later posts. For now, let’s move on to result types. 

About result types
If a user is able to see information about search results directly on the search results page, this will save them the hassle of having to click and open each item to see what it’s about. If you look back at theexample in the first section, you can easily see that the first two results are PowerPoint presentations, and that the third result is a Word document.  
To display search results differently, search results have to be sorted into different result types.  A result type distinguishes one search result from another. For example, if a search result is found in a Microsoft Word document, that search result belongs to the Microsoft Word result type. If a search result is found in a PDF file, that search result belongs to the PDF result type.

There are 31 default result types. To see them, go to Site Settings --> Result Types.

For an overview of the default result types, see this TechNet article. You needn’t worry about how default search results are specified; it’s something that happens "under the Hood" in SharePoint.

It’s not possible to edit any of the default result types. However, you can copy them, and add further configurations. I’ll show you how to do this in a later blog post, but first, it’s important that you understand how result types and display templates are connected.
  
About the connections between a result type and display templates
The mechanics of these connections are not particularly straight forward and easy to understand, but let's take a look at it in a step-by-step manner.
  1. Each result type contains a reference to an item display template, for example, Item_PowerPoint.
  2. Each item display template contains a reference to a hover panel display template, for example,Item_PowerPoint_HoverPanel.
Result type to display templates connections - 1


Let’s start with the first connection. To see the connection between a result type and an item display template, go to Site Settings --> Result Types. Select to view a result type, for example Microsoft PowerPoint.
View Microsoft PowerPoint result type
On the Result Type page, in the Display template URL section, you’ll see that there’s a URL that points to a file named Item_PowerPoint.js.
URL to display template
This URL is a reference to an item display template. This means that all search results that belong to theMicrosoft PowerPoint result type will be displayed by using the Item_PowerPoint.js display template.

If you look in the Master Page Gallery, you’ll see the Item_PowerPoint.js file and the associatedItem_PowerPoint.html file.

Item_PowerPoint display templates
Now for the second connection. To see the connection between an item display template and a hover panel display template, open Item_PowerPoint.html. You’ll see a reference to a hover panel display template, in this case, Item_PowerPoint_HoverPanel.js.
Reference from item display template to hover panel display template
If you look in the Master Page Gallery, you’ll find the Item_PowerPoint_HoverPanel.js file and the associated Item_PowerPoint_HoverPanel.html file.
Hover panel display templates in Master Page Gallery
 So now you can understand why there are so many search display templates. It’s because four display templates are connected to each result type.

For an overview of the connection between the default result types, item display templates, and hover panel display templates, see this TechNet article.

So, that was pretty straight forward. However, we’re not quite there yet. In addition to the display templates that are connected to a result type, there are additional display templates that are used by all result types.
  
About display templates that are used by all result types
To recap:
  1. Each result type contains a reference to an item display template.
  2. Each item display template contains a reference to a hover panel display template.
...and then we need to add:
  1. Each item display template contains a reference to a common item display template. 
  2. Each hover panel display template contain references to three common hover panel display templates.
Result type to display templates connections - 2
 These common display templates are located in the same Master Page Gallery folder as the display templates that are specific to individual result types.
Common display templates in Master Page Gallery
Each item display template points to the common item display template. The following screenshot shows how the item display template used for the Microsoft Excel result type points to the common display template Item_CommonItem_Body.
Reference to Item_CommonItem_Body display template
Each hover panel display template points to three common hover panel display templates. The following screenshot shows how the hover display template used for the Microsoft Excel result type points to the three common hover panel display templates.
Reference to the three common hover panel display templates
If all these references were a bit confusing, not to worry. In later blogs I’ll be using examples that will make it easier to understand.  At this point, it’s important that you understand how result types are used to categorize different types of search results, and how result types are connected to different display templates.  
  
About display template settings in the Search Results Web Part
Now for the easiest part of the puzzle: How does the Search Results Web Part know how to display search results based on the different result types?
On the search results page, click to edit the Search Results Web Part. In the Web Part Tool Pane, click to expand Display Templates.
Search Results Web Part configuration
 
You’ll see that the radio button Use result types to display items is selected by default. This means that search results will be displayed based on the result type that they belong to. That's it!
So now you know about the mechanics of how search results are displayed. In my next blog post, I'll go into detail about the item display template, and I’ll also explain the magic of hit highlighting.

How to add a custom action to the hover panel in SharePoint Server 2013

copyright from: SharePoint IT Pro Blog

This is a blog post in the series "How to change how search results are displayed". To demonstrate how you can customize your search results, I'll use examples from an internal Microsoft Search Center.

For an overview of the blog posts in this series, go to How to change how search results are displayed.
In the previous blog post, I showed you how to display values from custom managed properties in the hover panel. In this blog post we’ll learn:

What is a hover panel action?
Before I show you how to add a custom action to a hover panel, I want to make sure that you know what an action is.

At the bottom of the hover panel there are some links that are called actions. When you choose one of these, something will happen. For example, in my Search Center, when I choose “SEND”…
SEND action
… an email with a link to the list item will open.
New mail
To enable your visitors to do something with the search results, without having to leave the search results page, you can add a custom action.

In my Search Center scenario, I wanted to add a custom action that opens the published article. For example, for the search result “Customize search result types in SharePoint 2013”, I wanted to add an action that opens this link: http://technet.microsoft.com/en-us/library/dn135239.aspx.

How to add an action to the hover panel

In our lists, whenever an article is published, the URL to the published article is added to the list item. The screenshot below shows how the URL to the article “Customize search result types in SharePoint 2013” is maintained in the site column “Content Release URL”.
List item with site column Content Release URL
Because this URL is maintained in the list, I can add a custom action to the hover panel that will open this link.

In my previous post I showed you how the hover panel actions are rendered by theItem_Common_HoverPanel_Actions display template. So, to add a custom action, you have to edit this file.
However, similar to what we did when we added a custom property to the hover panel, you have to add the managed property that you want to use in your custom action to the item display template.

Confused? Well, trust me, this is not easy. It took me a while before understanding how things were connected, so let’s go through it step-by-step.

To add a custom action to the hover panel, here’s what you should do:
  1. Find the managed property name of the site column that you want to use. I showed you how to do this in a previous blog.
  2. In your mapped network drive, open an item display template. In the item display template, in theManagedPropertyMapping tag, use the following syntax to add the custom managed property:
    '':'

    In my scenario, I added the custom property that I wanted to use to the TechNet content display template.
Managed property added to display template
  1. NOTE: You do not need to do this step if you are using SharePoint Online.
    Go to Site settings --> Search Result Types. Notice that a Property Sync alert is displayed.
Property Sync alert

This alert is displayed because we have added a new managed property to an item display template (what we did in step 2). To update the result types with the newly added managed properties, chooseUpdate.

Update managed properties from display templates
IMPORTANT! If you don't do the update, the newly added managed properties will not display in your hover panel.
  1. Open the Item_Common_HoverPanel_Actions display template. See how the default actions are created, and use JavaScript and HTML to add your custom action.
    In my internal scenario, I looked at how the OPEN action ( _#= editHmtl =#_ ) is created. Based on that, I created a new action: _#= viewHtml =#_. The following screenshot shows what I did.
 Custom action added to display template
By doing a new search and hovering over a search result, I saw that my new custom action was displayed. Nice!
New custom action displayed
So now that you know how to change the way your search results are displayed, I have just one more thing that I want to show you: How you can change the text that is displayed in the Search Box Web Part.

Tuesday, May 12, 2015

How to create a new result type in SharePoint Server 2013

copyright from: blogs.technet.com

This is a blog post in the series "How to change the way search results are displayed in SharePoint Server 2013." To demonstrate how you can customize your search results, I'll use examples from an internal Microsoft Search Center.
For an overview of the blog posts in this series, go to How to change the way search results are displayed in SharePoint Server 2013.
In the previous blog post, I explained how item display templates and hit highlighting work. In this blog post we'll learn:
  
About the Search Center example in this series
To help explain how you can customize the way search results are displayed, I’ll use examples from a tool that I use on a daily basis: an internal list of Microsoft publications.
As you know, Microsoft publishes thousands of articles across TechNet, MSDN and office.com. To assist in the publishing process, we use several SharePoint lists. Each item in a list represents an article or a media file. To make it easy to find information about a particular list item, we created a Search Center that searches across these lists.
In our first version of the Search Center, all the search results were displayed identically. This was because by default, all list items belonged to the same SharePoint List Item result type. We wanted to change this so that just by glancing at the search results, we could distinguish between an article published on TechNet and an article published on MSDN. We also wanted to add important information about each search result that would be visible without having to select and open it.
Before we did anything in SharePoint, we sat down for a planning session. The first step was to decide how we wanted to categorize our search results. We came up with the following categories:
CategoryDefinition
TechNet contentArticles that have been published on the TechNet platform
MSDN contentArticles that have been published on the MSDN platform
Office.com contentArticles that have been published on the office.com platform
Images contentImages that are used in publications
Video contentVideos that are used in publications
Download contentDownloadable content
Once we had defined the categories, we then needed to distinguish the categories from each other. Items in our list contain a site column named Distribution Channel. This site column contains the value of the platform to which an article has been published, for example TechNet Library.
Distribution Channel value in a list item
We decided that we would use values from the Distribution Channel site column to distinguish the categories from each other.
With these decisions in hand, I set out to create new result types for each of the categories. The procedure for creating a new result type is identical for all categories, so to save space, I will only show you how I created the TechNet content result type.

How to copy a default item display template
Before you create a new result type, you should create a new item display template that your new result type will use.  To avoid having to create a new item display template from scratch, you can copy an existing one. Try to copy an item display template that is as close as possible to the type of content you have.  Here's what you should do:
  1. Copy a default item display template.
In my scenario, I wanted to customize search results for SharePoint list items. From this reference table I was able to determine that the default item display template that is used by the SharePoint List Itemresult type is the file named Item_Default.  Because I had mapped my network drive, I could easily copy the Item_Default file in Windows Explorer.
Copy Item_Default display template
By refreshing Windows Explorer, I could see that SharePoint had automatically created an associated JavaScript file.
JavaScript file created for Item_Default display template
  1. Rename your newly created item display template.
In my scenario, I renamed it TechNet content. Again, I refreshed Windows Explorer to verify that the JavaScript file was updated accordingly. 
TechNet content display templates
  1. Open the new display template and change the tag.  Remember, the text in this tag is what will be shown when you do configurations in the SharePoint UI.</li> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> In my scenario, I changed the <title> tag to <em>TechNet content</em>.</p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/1104.TechNetTitleTag.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/350x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/1104.TechNetTitleTag.png" alt="TechNet content <title> tag" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <ol start="4" style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <li style="margin-left: -10px;">Save the new item display template.</li> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> Now that we have created a new item display template, we can move on to creating a new result type.</p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;">   </p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <span style="font-size: medium;"><strong><span style="color: rgb(51, 51, 51);"><a name="CreateResultType" style="color: rgb(0, 116, 158); cursor: pointer; font-weight: normal;"></a>How to create a result type</span></strong></span></p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> Depending on your permission level, you create a result type on two levels:</p> <table cellpadding="3" border="1" style="border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(225, 225, 225); margin-left: 1px; color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"><tbody> <tr><td style="vertical-align: top; color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);"><strong>Permission level</strong></span></td><td style="vertical-align: top; color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);"><strong>Where the result type will be added</strong></span></td></tr> <tr><td style="vertical-align: top;">Site collection administrator</td><td style="vertical-align: top;">To all sites within a site collection</td></tr> <tr><td style="vertical-align: top;">Site collection owner</td><td style="vertical-align: top;">To a single site</td></tr> </tbody></table> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> To save space, I will only show you how to create a result type as a Site collection administrator.</p> <ol style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <li style="margin-left: -10px;">Go to <strong>Site settings</strong> --> <strong>Search Result Types</strong>.</li> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/5287.SearchResultTypes.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/5287.SearchResultTypes.png" alt="Search Result Type on Site Settings page" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> Instead of creating a new result type from scratch, you could make your life a bit easier by copying an existing result type and modifying it to fit your new result type. If you do this, ensure that you copy a result type that closely resembles the new result type you want to create. </p> <ol start="2" style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <li style="margin-left: -10px;"> On the <strong>Manage Result Types</strong> page, from the result type menu field, select <strong>Copy</strong>.</li> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> In my scenario, I wanted to customize search results for SharePoint list items, so I copied the <strong>SharePoint List Item</strong> result type.</p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/0876.CopySharePointListItem.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/400x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/0876.CopySharePointListItem.png" alt="Copy the SharePoint List Item result type" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <ol start="3" style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <li style="margin-left: -10px;">On the Add Result Type page, here's what you need to do:</li> </ol> <ol type="a" style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <li style="margin-left: -10px;">In the <strong>Give it a name</strong> field, enter a name for your new result type.  <br><br>In my scenario, I entered T<em>echNet content.</em></li> <li style="margin-left: -10px;">From the <strong>Which source should results match</strong> menu, select the result source that you have used to configure the query in your Search Result Web Part.</li> <li style="margin-left: -10px;">In the <strong>What types of content should match? You can skip this rule to match all content</strong> menu, all the default result type are listed. <br>In my scenario, I chose <strong>Select a value</strong>.</li> <li style="margin-left: -10px;">Click <strong>Show more conditions</strong>.</li> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/1362.ShowMoreConditions.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/1362.ShowMoreConditions.png" alt="Show More Conditions on Add Result Type page" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> This opens up a menu where you can specify the result type based on managed property values.</p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> In my scenario, all list items contain a site column called <em>Distribution Channel</em>. As I showed you at the beginning of this blog, this site column contains the publication platform value, for example <em>TechNet Library</em>. I wanted to use values from this site column to specify which list items should belong to my new result type</p> <ol style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"><ol start="5" type="a" style="list-style-type: lower-alpha;"> <li style="margin-left: -10px;">From the <strong>Which custom properties should match</strong> menu, I selected<em>DistributionChannelOWSCHCS</em>. <em>DistributionChannelOWSCHCS</em> is the managed property that represents the <em>Distribution Channel</em> site column. In the fields below, I entered all the values that should specify the new <em>TechNet content</em> result type.</li> </ol> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/6862.AddProperties.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/6862.AddProperties.png" alt="Add properties to specify the result type" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <ol style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"><ol start="6" type="a" style="list-style-type: lower-alpha;"> <li style="margin-left: -10px;">From the <strong>What should these results look like</strong> menu, select the display template that should be used by this result type.<br><br>In my scenario, I selected my newly created <em>TechNet content</em> display template. </li> </ol> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/5852.ApplyTechNetDisplayTemplate.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/5852.ApplyTechNetDisplayTemplate.png" alt="Apply display template to new result type" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <ol style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"><ol start="7" type="a" style="list-style-type: lower-alpha;"> <li style="margin-left: -10px;">Click <strong>Save</strong>.</li> </ol> </ol> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> Your newly created result type is now listed on the <strong>Managed Result Types</strong> page. <br><br>In my scenario, I could see that the <em>TechNet content</em> result type had been created.</p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> <a href="http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/0523.TechNetCreated.png" style="color: rgb(0, 116, 158); cursor: pointer; text-decoration: none; outline: none;"><img src="http://blogs.technet.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-66-12/0523.TechNetCreated.png" alt="New result type shown on page" border="0" style="overflow: hidden; max-width: 100%;"></a></p> <p style="color: rgb(42, 42, 42); font-family: 'Segoe UI', 'Helvetica Neue Light', 'Helvetica Neue', Calibri, 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12.960000038147px; line-height: 19.4400005340576px;"> So now that we have a new result type, the next step is to modify the display template that is associated with this result type. There are different ways you can go about doing this, so in the next two blog posts, I'll explain two different options.</p> </div>