Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a Sharepoint 2013 search display template working nicely. I wanted to add a new managed property mapping to the template which is of type "hyperlink or picture". This content type stores both a URL and description. It returns a comma separated value of link and description (ie. http://www.yahoo.com, my description). Not sure how to grab the link and description individually using $getItemValue from within the template?

Any pointers or examples would be much appreciated!

share|improve this question
add comment

1 Answer

From within the template you could get the value then split it using a JavaScript function e.g.

var commaSeparatedLinkAndDescription = ctx.CurrentItem.MyCustomProperty;

if(commaSeparatedLinkAndDescription){
     var array = commaSeparatedLinkAndDescription.split(','); 
}

Then assign the first and second array elements to variables for the URL and description.

var URL = array[0];
var Description = array[1];

Hope this helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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