Step 1: Pre-Filter Events on your Page
You can automatically filter your events so that visitors only see the set of events that meet the criteria you specify. To do so, add a filter to the initialization script:
apiFilters : [{"ANY LIVE API FIELD":{"CONDITION":["VALUE"]}}],
For example, if you have local store pages, and you want to put a calendar at the bottom of each that only shows events for the page’s location, you would add this filter:
apiFilters : [{"storeId":{"equalTo":["ID_OF_STORE"]}}],
To only show events with “Gourmet” in the name, include the following filter:
apiFilters : [{"name":{"contains":["Gourment"]}}],
With the filter below, your calendar will only show events scheduled after the current date:
<script>
var isoDate = new Date().toISOString();
var now = isoDate.substring(0, isoDate.lastIndexOf(':')).replace('T', ' ');
EventCalendar.Initialize({
apiKey: 'YOUR LIVE API KEY HERE',
resultsTemplate: '#result-template',
resultsElement: '#results',
apiFilters : [{"startDateTime":{"ga":[now]}}],
// the rest of your initialization script
});
</script>
You can use any well-formed Content Delivery API filter in your initialization script. For more information on Content Delivery API filters, see Using the Content Delivery API and the Content Delivery API documentation .
<% elem.innerText %>