I am trying to sort a collection list based on which user is logged in. Essentially, during onboarding, the user will choose their preferences and then I want to be able to sort the list based on the preferences saved in their cms item. Is there a way to do that? As an example:
Let’s say each user has a number that describes how much they like helping the environment. Each mission will include a grade on how much it is environmental and how much it is social, and I want to sort the missions based on the difference between the grade of the mission and the grade of the user, such that the user will get the missions they’re most interested in.
Is there a way to just write custom code that will filter/sort the list itself and then show it? It would be so much simpler.
Yes, it’s a bit involved, but you can create a custom sort function that evaluates the position of two items and sorts accordingly. You could do this by weighting the various attribute-scores of a CMS item against user preferences.
This is the harder part. If you’re using Webflow Memberships there currently is no in-built way to store/retrieve custom user information from script. You could use Sygnal’s User Info attribute to generate a unique user ID. However you’d still ideally want somewhere central to store and retrieve that data, possibly Make.com + AirTable?
That way you’d have the ability to log in to several systems and see your sort working properly. There’s a fair bit to build there, if you need help building it, my team offers Webflow micro-consulting.
Note that the simplest ( but limited ) way to build this is to ignore the user entirely, and store-retrieve the search setting on the machine itself. That’s not ideal if it’s a shared machine, but it can still improve the UX over a straight sort.
That depends entirely on how you design your scripts. However in your case, most of it will end up in your sorted page’s before /body code area.
Memberstack has a user metadata feature you should test out, and see if it works for you. The platform is generally more mature and complete than Webflow’s Memberships BETA currently is [ in Jan 23 ]. However it’s also less secure since it operates through client-side scripts, and adds additional monthly fees.
You’ll have to weigh the pros and cons depending on what you’re trying to do.