1

Working on a site in SP2013, I have created a custom display template to display a series of items. The problem is when I reference the publishing hyperlink field in the html as the src value of my a href tag it doesn't render correctly.

<div id="Item_WebPage">

    if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
        var id = ctx.ClientControl.get_nextUniqueId();
        var _title = $getItemValue(ctx, "Title");
        var _linkUrl = $getItemValue(ctx, "Link URL");
        var _teamMembers = $getItemValue(ctx, "Team Members");
        var _briefDescription = $getItemValue(ctx, "Brief Description");
        var _relatedLinks = $getItemValue(ctx, "Related Links");
        var _relatedDocuments = $getItemValue(ctx, "Related Documents");


                                <div class="row engagement-team">
                            <div class="col-12 noPadding">
                                <a href="_#= _linkUrl =#_"><h2>_#= _title =#_</h2></a>
                                <h3>_#= STSHtmlDecode(_teamMembers.value) =#_</h3>
                                <p>_#= STSHtmlDecode(_briefDescription.value) =#_ </p>

                            </div>
                            <div class="col-12 col-sm-6 noPadding">
                            <h3>related links</h3>
                                _#= STSHtmlDecode(_relatedLinks.value) =#_
                            </div>
                            <div class="col-12 col-sm-6 noPadding">
                            <h3>related documents</h3>
                                _#= STSHtmlDecode(_relatedDocuments.value) =#_
                            </div>
                        </div>

It ends up rendering as follows (The value in the hyperlink field is https://www.google.com)

<a href="&lt;a href=" https&#58;="" google.com"="">google.com</a>

I assumed this is because it is grabbing more than the hyperlink value from the column. Is there a way I can parse this value so that it returns only the hyperlink value added as the src in my a href? Any advice would be appreciated.

1
  • which is the problematic one ? _linkUrl or _relatedLinks ? Aug 31, 2018 at 5:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.