Monday, May 20, 2013

SharePoint 2013 Search: Modifying Promoted Result Displays

A question came up during my Search sessions at SPS Baltimore this past weekend. It was in regards to Promoted Results taking the place of Best Bets and the icon being used.

The icon is no longer a star but a blue check mark:

Search uses the Item_BestBet display template to present these promoted results. You may find the template in your Search Display Templates folder:
 


 
You may make modifications to this template to change how promoted results are rendered. The specific question dealt with the icon. There is a div and an img tag located in the template file:
 



This is using a sprite image named searchresultsui.png which is made up of various icons that are used within the search results. Obviously it is using the blue checkmark portion of the sprite. If you wanted, you could modify the image tag to use a different image as the promoted results icon.





 

20 comments:

  1. Hello Steve,

    few weeks ago I've asked you something regarding to "adding people to everything". Again, thanks for your response. But now I have a problem regarding to promoted results. I've read a lot of blogs to this and I've done the same, but my promoted result is displayed incorrectly. Only the title is visible. The URL and description are not visible and the URL does not work.

    Can you help me?

    Thanks a lot!

    ReplyDelete
    Replies
    1. Have you modified the Best Bets template at all? I would go into SharePoint Designer and reset the best bets template to site definition. Let me know if you need the steps.

      Delete
    2. What should I modify? Cause I'm comfortable with the blue check mark. I have the problem that it basically does not work. Can you may show me the step how to reset the best bets template to site definition? Maybe it is good for you to know that I use a vary version of the display template "item_default.html" for the everything-site. Cause I had to do some modifications.

      I don't know if it's useful for you :-).

      Thanks again.

      Delete
    3. Maybe you have an extra tag or some syntax error in item_default that is causing the promoted result html to get goofed.

      Delete
    4. Could you tell me which part in item_default is responsible for promoted result?

      Delete
    5. What do you mean: Is it possible to get a false promoted result if I have a special pagelayout? Maybe my friend has forgotten to define something? Furthermore I am using a result.aspx for the page which I've done by myself, too.

      I'm not sure if I have to define something special in pagelayout or page?

      Thank you

      Delete
    6. Oh, I think I have the solution. I build up a new Search without any changes and if I create a new query rule it works. While I edit the page (or rather the search results) I saw that the display template is "using result type rules to decide" to display items. In my opinion, that means I realy use the Item_BestBets. In the other Search I use a single template to display items (special_item_default). The problem here is I don't use the Item_BestBet to display promoted results. The normal item_default display template displays the promoted results incorrectly, too. So I have to take the option "use result type rules to decide". Or I have to copy the item_BestBets code into my special_item_default display template.

      Sorry for posting so much stuff :-).

      Delete
    7. Control_SearchResults is the main template that handles the grouping of results by using Group_Default template. The Item_BestBest is for a promoted result and is used in the promoted result grouping. The Item_Default is used for regular search results. Since all of these templates call each other and what not, if the resultant HTML is not correct, it could cause issues. This is what I thought originally for your issue.

      You should "use result type rules to decide". I think you figured out your issue in that the promoted result was using the wrong template.

      Delete
    8. Thank you a lot Steve.

      I can't use "result type rules to decide", because I have a lot of modifications in my search result and thats why I use a special display template.

      Could there be a problem if I copy the item_BestBets code into my speacial_item_default display?

      Delete
    9. I am not sure if that would work as the promoted results are called from the control and group templates. Doesn't hurt to try. If I had time I would figure something out but I need to work on a group project for one if my classes.

      Delete
    10. Okay, I will try it. And if it's work I will explain the solution.

      Thank you.

      Delete
    11. Hello Steve,

      I've found out a nice solution. At first I create a new result type. In this step I choose "All Sources" and skip "What types of content should match?". So I match all content. And now the most important thing is the question "What should these results look like?". Here I'm going to choose my special_item_default. Now, all my results will displayed in the right way.
      The next step is to edit my Search Result webpart. Here I can switch the option to "use result type rules to decide".

      Now the Item_BestBet will called.

      Thank you a lot Steve.

      Delete
    12. Hi Steve

      I don't know why but my promoted results are displayed a little bit wrong. The description is right behind the title. It should be under my title. I have no changes in my Item_BestBet.

      Do you know a solution?

      Delete
    13. Could be the browser. Check the browser compatibility setting (F12). See if changing them fixes the rendering.

      Delete
    14. I have checked the browser compatibility setting and everything is correct...

      Delete
    15. Have you modified any CSS settings? Use the Developer tools (F12) to trace the styles that are being applied. Maybe something is being overridden.

      Delete
    16. Steve, you are the best! My colleagues has a own css-file which overwrites the other css-files. Amazing! Thank you a lot.

      Delete
  2. Hello Steve, do you know how to make promoted results for different languages? We are using two languages: german and englisch (us). I would like to creat a promoted result for a german user with german description and the same promoted result for an english user with english description.

    ReplyDelete
    Replies
    1. I don't have a spectacular solution at the moment. You could have two promoted results - one based on English keywords and one based on the German words. Another option would be to just show both regardless. I'll dig in some more and see if there is a slicker implementation.

      Delete

Matched Content