SharePoint 2013 - Display templates - get the web part zone - web part properties / parameters
-
10-12-2019 - |
Question
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:
Solution
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);
});
});
_#-->