0

SharePoint 2010

I'm trying to color-code the search results of a Core Results web part based on the color of the title of the result.

More info: This search is set with a scope to only find results within a Knowledge Base, set up as a collection of pages. The Knowledge Base titles of the articles are given a color based on their category, and the team asked me to have the Core Results web part color-code search results so the search result title matches the color of the article title.

I've pulled the XSL, XML for the results, and HTML of two different pages (with different colors), and it seems that I will want to change either the HitHiglighting template in the XSL or the HHTitle element in the XML.

I've found ways to change which columns show up, but haven't been able to find anything quite this extensive.

As for my skillset background, I'm new in this SharePoint BA position and have never worked with XSL, though it's beginning to make sense as I'm working with it, and I have some background in XML and HTML

  • Sounds like you are using SharePoint 2010? – Matthew McDermott Jul 13 '16 at 14:22
  • XSL is tedious, it's WAY easier in 2013/2016. You can start with some of my old posts: ableblue.com/blog/?s=XSL look at this one to get started: ableblue.com/blog/archive/2011/09/09/… – Matthew McDermott Jul 13 '16 at 14:27
  • @MatthewMcDermott sorry, yes, that is correct. I'll edit the question to reflect that. – rolemartyr-x Jul 13 '16 at 15:53
  • No worries, have a look at those old blog posts. You essentially have to just set the style on the result item. – Matthew McDermott Jul 13 '16 at 15:54
  • Thanks for the help! Your posts helped me to come up with the answer and realize that she and I were not talking about the same kind of "title"! – rolemartyr-x Jul 14 '16 at 19:44
0

TLDR: This request is not possible as stated due to text "titles" not being the same as a page's <title>

Reasoning:

The requestor was asking to change the title of the Search Results to the color the first line of the page uses (what she referred to as the "title" of the page).

However, the search result title and her top-of-the-page "title" are not the same element; her "title" is not an element in itself, just text in a <div>, and the title Search uses is the element <title>.

Since a <title> is metadata, it cannot be assigned a color (or, it would typically be pointless to do so, if you can), and so there is no way to bring that color through to the Search Results page.

A possible workaround would be to change the search results to pull the first X number of characters from the page instead of the <title> element, but this would result in a mess, as not all the "titles" of the pages are the same length, so some would get cut off and others would include the beginning of the next paragraph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.