Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: Make filter URLs pretty #1221

Merged
merged 1 commit into from
Jan 26, 2024
Merged

Events: Make filter URLs pretty #1221

merged 1 commit into from
Jan 26, 2024

Conversation

iandunn
Copy link
Member

@iandunn iandunn commented Jan 23, 2024

Fixes #1196

WIP

When finished, applying filters should result in a URL like https://events.wordpress.test/upcoming-events/filtered/format/online/ and
https://events.wordpress.test/upcoming-events/filtered/format/in-person/type/wordcamp/month/january,february/country/united-states,germany/. Currently that's only partially working.

When finished, you should also be able to start at https://events.wordpress.test/upcoming-events/ and apply filters to get to a "pretty" URL like the one above, rather than the key-value pairs shown in #1196. This part will probably require some modification to the query-filters block, to append the selected filters to the form action in JS.

@iandunn iandunn added this to the Events: Promotion milestone Jan 23, 2024
@iandunn iandunn self-assigned this Jan 23, 2024
@iandunn iandunn changed the title Event facet rewrites Jan 23, 2024
@iandunn iandunn force-pushed the event-facet-rewrites branch 2 times, most recently from 6164504 to 0fa0c44 Compare January 23, 2024 22:44
@iandunn
Copy link
Member Author

iandunn commented Jan 23, 2024

I setup a rewrite rule so that URLs like https://events.wordpress.test/upcoming-events/filtered/format/online/ will be treated the same as https://events.wordpress.test/upcoming-events/?format_type=online. That part works.

The other main part of this is to redirect the user to that type of URL when they select filters in the query-filters block. That currently isn't working, the filters still get added to the URL as encoded key-value pairs, because they're being created as input fields.

One solution would be so enqueue some JS from this theme, and update the <form action="..."> on the fly when the user selects a value from an instance of the block, and also remove the <input> fields from the form on submit. That doesn't feel very elegant, though.

Another solution would be to modify the query-filters block directly, but I think that'd add tech debt.

This is related to previous work around treating the arbitrary event data work as WP_Query results. See #1124 and #1156.

@StevenDufresne , @ryelle: i'm curious what you think about this.

@iandunn
Copy link
Member Author

iandunn commented Jan 24, 2024

Ah, I see now that Showcase submits to the URL with key-value pairs, then redirects to the "pretty" one. That should work here too 👍🏻

@iandunn iandunn force-pushed the event-facet-rewrites branch 4 times, most recently from c5b6f42 to 22c8ea7 Compare January 26, 2024 19:45
@iandunn iandunn marked this pull request as ready for review January 26, 2024 19:58
@iandunn iandunn merged commit 9ee5854 into production Jan 26, 2024
3 checks passed
@iandunn iandunn deleted the event-facet-rewrites branch January 26, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant