4

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

3
  • 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? Feb 26, 2014 at 13:27
  • I just want to recieve the web part property (zone under layouts when editing a web part)
    – Plexus81
    Feb 26, 2014 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. Feb 26, 2014 at 14:53

1 Answer 1

1

One solution found link below:

sharepoint-2013-display-templates-media-queries-to-get-image-rendition-on

<!--#_
AddPostRenderCallback(ctx, function()
{    
     var width = $(window).width();
     var rendition = '?RenditionID=2'; 
     if(width <= 320){
         rendition = '?RenditionID=1';
     }
     jQuery('.image-to-fix').each(function(){
           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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.