Hamish this problem fascinates me, because I hate “it can’t be done” problems.
In your scenario, most of the approaches we’ve been exploring in the other thread won’t work well - they’re focused on Tags, which are simple structures, and many-to-many.
With Venues-to-Events, you probably have a 1-to-many relationship. I’ll assume you’ve designed it so that each Event has a Reference field (not Multi Reference) to one Venue only. If that’s true, there is a solution, which involves a tiny bit of script.
The page design would look like this-
Venues Collection List
- Style however you want
- Filter and sort as needed
- Within each Venue Collection Item, place an HTML Embed where the Events will go. In that embed, you’ll do something like this;
<div ui="venue-events" selector="venue-id-1">
</div>
Where venue-id-1
is your embedded Venue Slug (since it’s guaranteed unique).
Events Collection List
Then separately, below your Venues Collection List, you create your Events Collection List-
- Style however you want. Wrap it inside of a “mock” venue, so you can see exactly how it will display visually, when you want to.
- Filter it to current & upcoming events ( whatever you want to appear ).
- Sort how you want. **
- Wrap the entire Events Collection List, including the mock venue, in a Section, so that you can conveniently hide it. This section won’t be visible to your website visitors.
- Within each Event Collection Item, place an HTML Embed. In that embed, you’ll put the Venue slug, so we can stitch them together later;
<div ui="event" selector="venue-id-1">
</div>
Where venue-id-1
is the embedded-field Slug of the linked Venue.
Moving your Event items to their corresponding Venue
In the end-user’s web browser, we’ll have a small script run as soon as the page is loaded. We want to select all of the Event DIVs, and relocate them to their corresponding Venue Events DIV.
jQuery makes this stitching-up pretty simple.
// Select all of the venue events container DIVs, and iterate through them
$('div[ui="venue-events"]' ).each(function( index ) {
// prepare the venue ID selector string, for event-to-venue matching
var matchingVenue = "selector=" + $( this ).attr( "selector" );
// for each venue, move the corresponding events which have that venue ID
// note that we want the parent's parent of this DIV, to get the whole Event element,
// because Webflow wraps HTML Embeds in a DIV.
$(this).append( $('div[ui="event"][' + matchingVenue + ']').parent().parent() );
});
In English that reads as;
- Select all of the
ui="venue-events"
DIVs, and iterate through each of them
- For each Venue, locate all of the
ui="event"
DIVs which have the same selector value
- Get the parent of that DIV, since the DIV is within the event frame, rather than being on the frame directly.
- Move that event DIV to the correct venue
I decided to give this a go, and it works smoothly. You can play with it here-
** I’m not 100% certain that the initial sort order will be preserved in the move process, so keep an eye on this. If you encounter problems you may need to re-sort your per-Venue Events Lists after the Events are moved. There is a way to do that, so let me know if you get stuck.