Events Priority

Sep 5, 2014 3:38 pm

In our events module, we have a feature called "Priority". At its most basic, priority is a simple text field attached to an event which you can insert an integer into.

This can subsequently be used to sort or filter a lister, which by default is sorted by event date then time. Some examples of what you can do with the priority field: you can have a lister sort events with priority from low to high, or can filter a lister so only events with a certain priority are shown. You can even use this to force certain events to the top of the event list, like a pinned forum post.

We will walk you through the steps of setting up a basic lister which sorts by priority. Navigate to the module layouts (Green > Layouts > Modules) and edit the default events lister, or make a copy to edit. In the field "Sort Field", type "priority". This forces the lister to sort by the priority that we give each event rather than the default sorting value.

Once you save we are ready to move onto the next step. You will now need to go to the events and edit them to give them a priority (Blue > Events > click Edit). Ensure that each one has a priority - leaving the priority field blank automatically pushes it above any entries which have a priority. Before adding priorities, you can see that the default sorting order was date, then time, as you can see below.

When setting this up, we set the priorities up so that the default sort order would be reversed - test item 1 got priority 4, item 2 was assigned priority 3, etc. As you can see from the screenshot below, the priority has overridden the date and time values as what the lister uses to sort our events.

Congratulations, you have completed the setup!

Sep 8, 2014 2:00 pm

Great post Andrew.

To add to this, if you want the events with "blank" display priority fields to display last & the events with display priority 1, 2, 3, etc to appear above the blank ones, this can be done!

First, do everything Andrew mentioned above.

Next, in the Events Default Lister step (Green > Layouts > Modules) in which Andrew said put in the word "priority" for the sort field, instead, put in the following:

The priority DESC will put the priority in reverse order. (Blank events will be on the bottom & higher number priority will be on top).
The event_date after will sort by event_date if priority levels are the same number (or blank with no number).

Note: Items with Priority Display of 1, 2, 3 will display 3, 2, 1 now because of the descending order, but it will keep the blank ones below the priority preference events

The final screenshot has Test 1, Test 2, & Test 3 events with blank Display Priority, Test 4 has Display Priority 1:

You have now automatically kept events with blank Display Priority to remain below those with Display Priority preferences.

Sep 8, 2014 2:50 pm

Thanks Andy, very helpful information.