How to dynamically change the Event Calendar layout

The default settings of the Event Calendar widget allows you to choose only one layout. However, we are happy to say that you can still use a single Event Calendar widget in multiple layouts all at once. This article will provide a step-by-step guide to help you set this up.

In this article

Why you may need this feature

This feature can be quite useful when you need to use a single Event Calendar widget in various layouts on different pages of your website. For example, you might want to display the widget with the List layout on a dedicated “Events” page, while having the Grid layout on your website's main page. 

In the past, you had to create multiple Event Calendar widgets with the same content but with different layouts and then install them on the desired pages individually. However, with the method outlined in this article, you can skip the process of creating multiple widgets.

How to use the widget in different layouts

To make the widget change its layout dynamically depending on the page it's installed on, you need to use the following attribute:


This attribute, when added to the widget installation code, specifies the layout the widget should have on the page where it is added. For instance, if the widget's default layout is List, but you prefer it to have the Grid layout on a specific page of your website, you should insert the widget installation code on that page in the following manner:

<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="grid" class="elfsight-app-WIDGET_ID"></div>
Don't forget that WIDGET_ID in the code above should be replaced with the actual ID of your own widget - Where to get your widget ID.

In this case, all the settings of the Grid layout that you have selected within the widget's editor will be applied to the widget on this specific page. As for the other pages where you have this widget installed, the widget there will still have the List layout, unless you choose to have different layouts on some of those pages as well.

To sum up, to dynamically change the widget's layout to a different one on a specific page of your website, its installation code should be added as follows:

For the Grid layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="grid" class="elfsight-app-WIDGET_ID"></div>
For the List layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="list" class="elfsight-app-WIDGET_ID"></div>
For the Masonry layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="masonry" class="elfsight-app-WIDGET_ID"></div>
For the Slider layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="slider" class="elfsight-app-WIDGET_ID"></div>
For the Month layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="month" class="elfsight-app-WIDGET_ID"></div>
For the Week layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="week" class="elfsight-app-WIDGET_ID"></div>
For the Day layout:
<script src="" data-use-service-core defer></script>
<div data-elfsight-app-layout="day" class="elfsight-app-WIDGET_ID"></div>

Well done. Now that you know about this feature, you can efficiently use it to display your Event Calendar widget in multiple layouts at the same time!

Didn't find the answer you were looking for? Contact our Support Team. We're here to assist!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us