0

Currently working on a site in Sharepoint 2013, I have created a custom item display template to display links to related pages across the site on a page via the content search webpart. The items are set to use a publishing hyperlink field for the user to add a page url for the item to link off to when the item is clicked. The html for the template is structured as follows:

<div class="training-link">
   <a href="_#= _linkUrl =#_">
     <h3>_#= _title =#_</h3>
   </a>
</div>

Unfortunately when I attempt to grab that field value via the publishing hyperlink managed property, the webpart renders like so:

<div class="training-link">                                       
   <a href="&lt;a href=" sites="" deed-ui="" pages="" mass-layoff-
   archives.aspx"="" target="_blank">Mass-Layoff-Archives.aspx</a>"&gt;                                            
   <h3>Test Link 3</h3>                                                                            
</div>

For reference, the value input for the publishing hyperlink field for the above item was:

/sites/deed-ui/pages/mass-layoff-archives.aspx

I want to be able to grab only the information entered into that field of the item and set it as the href for the item. Unsure as to why the display template interprets the field value in such a strange way. Any help for how to troubleshoot is appreciated.

0

Looks like you have added an extra under score which is causing wrong href link.

Modify it as below:

<a href="_#= linkUrl =#_" target="_blank">
     <h3>_#= title =#_</h3>
</a>

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.