Can you expose configurable parameters from a display template in the web part editor part?

I am working on customizing display templates for the Content Search web part. I have a custom item template, and a custom control template. I’m going to be setting up several similar web parts, and in each of them the query is going to be changed to point only at a single list.

What I want to do is put a “View all” link at the bottom of the control template that goes to the list that the search web part is displaying items from.

Is there a way to do some markup in the control template that would expose a text box in the web part editor part so I can configure the URL that the “View all” link should point to?



1 Answer


That is only possible if you extend the CSWP, but you configure the query to point to a single list you say. Then it is not required to have such a property. What you can do is add some code to your item display template to show a “view all” link once the last item got processed. This link needs to point to the list or library, which can be retrieved from the ParentLink property.

So in your managed property mappings attribute, add the ParentLink property:

‘Link URL'{Link URL}:’Path’,’Line 1′{Line 1}:’Title’,’Line 2′{Line 2}:”,’FileExtension’,’SecondaryFileExtension’,’ParentLink’

At the end of the item template add the following code to insert the view all link on your page:

Here is the whole example:

Two lines – View All

_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_

_#= line1 =#_

_#= line2 =#_



Fantastic! That worked perfectly, thanks!
– Dylan Cristy
Jan 9 ’15 at 14:53



Is there another property on the item like ParentLink that would be the URL of the item’s parent web?
– Dylan Cristy
Jan 9 ’15 at 15:56



You have SPWebURL on SharePoint Online, but you could also get it on-premises:…
– Elio Struyf
Jan 9 ’15 at 20:18



Ah, perfect! I’m developing on-prem but ultimately it will all be deployed online, so that’s exactly what I need. Thanks again!
– Dylan Cristy
Jan 9 ’15 at 21:10