Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Search results title length

$
0
0

The title length of items in the search results is getting limited to 60 characters, with the last three being "...". I have found that I can display the whole title by changing Item_CommonItem_Body.html in display templates. I change this code:

var titleHtml = String.format('<a clicktype="{0}" id="{1}" href="{2}" class="ms-srch-item-link" title="{3}" onfocus="{4}" {5}>{6}</a>',
                                          $htmlEncode(clickType), $htmlEncode(id + Srch.U.Ids.titleLink), $urlHtmlEncode(url), $htmlEncode(ctx.CurrentItem.Title), 
                                          showHoverPanelCallback, appAttribs, Srch.U.trimTitle(title, maxTitleLengthInChars, termsToUse));

to this code (only change is putting 3 instead of 6 for where the text for the anchor tag gets written)

var titleHtml = String.format('<a clicktype="{0}" id="{1}" href="{2}" class="ms-srch-item-link" title="{3}" onfocus="{4}" {5}>{3}</a>',
                                          $htmlEncode(clickType), $htmlEncode(id + Srch.U.Ids.titleLink), $urlHtmlEncode(url), $htmlEncode(ctx.CurrentItem.Title), 
                                          showHoverPanelCallback, appAttribs, Srch.U.trimTitle(title, maxTitleLengthInChars, termsToUse));

But doing this removes highlighting of search terms in the title. I would prefer to be able to set the maxTitleLengthInChars. But this doesn't seem to be possible. If I replace maxTitleLengthInChars in the above code with 255 it still only returns 60 characters. I also tried setting var maxTitleLengthInChars = 255 instead of var maxTitleLengthInChars = Srch.U.titleTruncationLength;

But that too had no affect. If anyone knows how to set the maxTitleLengthInChars please tell me where and how? I can't find any setting in the search results web part to set it.

Thanks
Craig


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>