Do you need a simple filter to show/hide seminar events from a selected location in Totara LMS?
We needed to run multiple events across multiple locations for our courses and we needed to do so across more than 50 different office locations. Since there may be 200 to 300 events every year for each course… we realised that it would be handy for the learners and admins to be able to filter by location (or the default Room).
As illustrated by the image above, it is possible to create a dynamic dropdown to filter Upcoming Events by Site (a custom Event field) by adding some code. We want to:
- Hide all events on load.
- Display a dynamically generated Site: Choose location dropdown.
- Show all scheduled events when ‘All locations’ is selected.
- Only show upcoming events for a location that is chosen (i.e. if scheduled).
- The previous events list is not modified.
- We can continue to use the Rooms Location feature to specify specific rooms.
I am a Learning Management System (LMS) Administrator and I first published this post at https://www.linkedin.com/pulse/seminar-events-filter-location-totara-lms-vijay-rudraraju
This code works in Totara LMS v12.
Steps to enable this dropdown to filter events by location
There are just 3 steps to enable this locations filter:
- Add a Site custom field to store the event location.
- Create the events (including Site location).
- Add the script to enable the dynamic filter.
1. Add a Site custom field to store the event location
Go to Site administration > Seminars > Custom fields (/mod/facetoface/customfields.php?prefix=facetofacesession) and create a custom field called Site to capture the location. I decided to use a choice field (you can make it a required field).
Refer to Creating custom fields – Totara Help 13 – Totara Help (totaralearning.com)
2. Create the events (including Site location)
When adding the event to your seminar, trainers can select the Site from the Custom Fields section. Refer to Seminar events – Totara Help 13 – Totara Help (totaralearning.com)
3. Add the script to enable the filter
Add the JavaScript (JS) code provided for you on my codepen to your site or course within <script> </script> tags.
Note: You can add the code sitewide across LMS via /admin/settings.php?section=additionalhtml to activate this filter on all seminar events or load it for an individual course via HTML block. Refer to my post on How to add code to enhance Totara LMS on LinkedIn
That’s it!
I hope you found this useful!
Please comment and share your own thoughts on this technique…