3

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!

1

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!

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.