MODULES
...
Siteglide Modules
Events
Browse by Event Dates
23min
this option allows you to provide the user with links to months when events are happening or let them search between any two dates prerequisites you've installed the events module you've updated your system files to at least version 2 4 4 0 introduction this article will show how to add a parameter to the main events module "include" liquid tag to enable advanced filtering by event start and event end dates how to include the archive navigation feature an explanation of the three main sub layouts available in in the default layout (1) search between two dates (2) browse by months (3) browse by months under year header how to give user feedback about search results add "use adv search" parameter to include for event list view the "use adv search" parameter is needed to allow filtering from the url to apply to your event items, this can be added to the include for event list like so {% include 'module' id '12' layout 'default' per page '20' show pagination 'true' sort type 'created at' sort order 'desc' use adv search 'true' %} past events and future events by default, the list view will show all events that are enabled, released and not yet expired if you just want to filter the list so it either shows events that have already happened in the past or those events which will happen in the future, it may not be necessary to include the entire archive feature filter by past events {% assign now = "now" | date "%s" %} future events filter by future events {% assign now = "now" | date "%s" %} past events using liquid logic to "toggle" between past and future events {% assign now = "now" | date "%s" %} {% if context params range type == "past" %} past events future events {% elsif context params range type == "future" %} future events past events {% else %} all events past events {% endif %} including the archive navigation feature firstly, you will need to provide the following liquid to include your archive layout {% include 'modules/siteglide events/get/get events archive' archive layout "design system/1/archive" archive layout type "sidebar years and date search" %} parameters archive layout the layout parameter refers to the main layout folder followed by a path to the folder storing any archive layouts you are using in the example, an /archive folder is used archive layout type the type parameter refers to the name of the archive layout file in the default/archive/ folder we have 3 different optional types of archive layout you can choose by entering their names in the type parameter we will show the liquid tag for including each include browse by months {% include 'modules/siteglide events/get/get events archive' archive layout "design system/1/archive" archive layout type "sidebar" %} include browse by months under years header {% include 'modules/siteglide events/get/get events archive' archive layout "design system/1/archive" archive layout type "sidebar years" %} include search events between two dates {% include 'modules/siteglide events/get/get events archive' archive layout "design system/1/archive" archive layout type "sidebar years and date search" %} events archive layouts the following examples will take you through the different options browse by month archive {% for month in events archive months %} {{month start | date "%b %y" }} {% endfor %} in this example, we use the events archive months object and loop over the array for each iteration, a url link is outputted which has three range parameters `range gte` = an epoch format date for midnight on the beginning of the first day of the selected month range lt = the date above + 1 month we don't use lte because the date is the first valid date in the next month we want every date up until then range field =events this parameter is important as it makes sure that the event start and event end fields are used instead of release date for the filtering browse by months, organised into years this layout does not just organise the months available under the relevant year headers, it also will skip any years without an event archive by years {% for year in events archive years %} {{year start | date "%y"}} {% assign months by year = events archive months | group by "year" %} {% for month in months by year\[year start] %} {{month start | date "%b" }} {% endfor %} {% endfor %} this example uses the same links as the previous one however, it also organises the links into the years in which they belong by first looping over the years in the events archive years and then using the group by liquid filter and another loop to output the month links grouped under the current iteration's year learn more about this liquid at the pos docs group by filter https //documentation platformos com/api reference/liquid/platformos filters#group by for loop https //documentation platformos com/api reference/liquid/loops search events between two dates in the default layout, this option also includes the previous "browse by months organised into years" option for convenience though the code can be simply removed if you prefer we have removed it in this article's example it also adds a form for directly manipulating the url parameters to find the exact dates the user is interested in archive by years {% assign events archive years = events archive years | sort "start" %} {% for year in events archive years %} {{year start | date "%y"}} {% assign months by year = events archive months | sort "start" | group by "year" %} {% for month in months by year\[year start] %} {{month start | date "%b" }} {% endfor %} {% endfor %} {% assign now = "now" | date "%s" %} all past events all future events search by date start date end date {% comment %} add your custom error message here it can be renamed by changing its name in the argument for the s events date search function and in the definition below {% endcomment %} in this example a form is used to take user input the siteglide function automatically adds the dates to the url parameters in the correct format you can rewrite the error function to customise the way the form handles invalid dates entered a note about date entry inputs on different browsers different browsers may display the date input fields very differently 3rd party javascript plugins are available for making sure these display with your desired design custom layouts this is a relatively complex feature, so some understanding of liquid will be necessary to understand how to create a custom layout the best way to start would be to copy one of the default layouts and edit it to provide the changes you need any layouts included with the above liquid will get access to the events archive years and events archive months arrays, which contain detailed data about the years and months respectively which contain valid events this can be used to generate dynamic buttons to the user so they can browse events archive years {% for year in events archive years %} {{year start}} {{year end}} {% endfor %} events archive months {% for year in events archive years %} {{year start}} {{year end}} {% endfor %} in order to filter the events list by date, you need to refresh the page url with parameters in the unix epoch time https //www unixtimestamp com/index php format the following url parameters will cause results in the list to filter range gt greater than range gte greater than or equal to range lt less than range lte less than or equal to for the above to work, remember to set the use adv search true parameter (see start of article)! the pos documentation website has some useful tips on how to use liquid to convert date formats and manipulate dates and times see the following useful filters, and browse the docs for more localize https //documentation platformos com/api reference/liquid/platformos filters#localize aliases l date https //documentation platformos com/api reference/liquid/platformos filters#localize aliases l add to time https //documentation platformos com/api reference/liquid/platformos filters#add to time feedback for the user displaying the currently applied filter in the examples, you may notice another url parameter is used range type the s events date search siteglide function for filtering events by user inputted dates adds the parameter range type="between" this would allow the following liquid on the list layout to identify that this search is between two dates {% if context params range type == "between" %} events between {{context params range gt | date "%d %b %y"}} {{context params range gte | date "%d %b %y"}} and {{context params range lt | date "%d %b %y"}} {{context params range lte | date "%d %b %y"}} {% endif %} whereas, you could use another range type to indicate that different feedback should be given to the user e g the parameter month in this example changes the sentence structure from "events between" to "events in" to communicate the different kind of filtering that is now taking place {% if context params range type == "month" %} events in {{context params range gt | date "%b %y"}} {{context params range gte | date "%b %y"}} {% endif %} note in both of these examples the gte and gt dates are both outputted this is because only one is expected to be available the layout is designed to accept either