Is there a way to list what web part properties the actual display template is using? I want to display what web part zone the display templates are using? This without iheriting the ContentBySearchWebPart, see link below?

pass parameters to the control display template

I want is to have a dynamic display template based on the width / zone of the web part. What I mean with dynamic, is that you get different info / layout / branding based on what zone the display template is in. I'm using responsive design and I don't want to calculate the width using javascript (calculating the parent div.. )

How can I get the property in yellow, see image below: example image

  • You are talking width, and then webpart zones, would it not be enough to with JavaScript just query the parent element for its width and use that info in the rest of your rendering? – Robert Lindgren Feb 26 '14 at 13:27
  • I just want to recieve the web part property (zone under layouts when editing a web part) – Plexus81 Feb 26 '14 at 13:45
  • I don't know of a way other than what Robert Lindgren already proposed. Regarding passing parameters to your display template, this is best done like so: Define some managed properties where you can pass your values. Although it's alwyas used for displaying fields, I don't believe this is absolutely necessary since you can get at the real value through the display templates javascript, after which you could put it in a div's class tag or something. – Cameron Verhelst Feb 26 '14 at 14:53

One solution found link below:


AddPostRenderCallback(ctx, function()
     var width = $(window).width();
     var rendition = '?RenditionID=2'; 
     if(width <= 320){
         rendition = '?RenditionID=1';
           jQuery(this).css('background-image', jQuery(this).attr('data-image') + rendition);

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.