I’m working on a website that lists events in a calendar layout (date, title). Each event is organised into family and parent categories, and each event has a detail page to show further information (content, images…).
This is managed via MIGXdb and the output from the Family, Parent and Event tables is like
- events
- cycling (family)
- sport (parent)
- 2023-12-04 Time Trial Round 4 (event detail)
- 2024-01-19 Time Trial Round 5
- expert (parent)
- sport (parent)
- rugby (family)
- under 16s (parent)
- 2024-05-12 Junior Cup Round 1
- adults
- under 16s (parent)
- cycling (family)
The easy option to access the detail page is with a querystring eg. /events/detail?event_id=123 but this is not very user friendly. Instead the event detail URL should be like
/events/family/parent/yyyy-mm-dd--the-event-title-slug/
The date is included here as there is a high chance of future events having the same family, parent and title as they are annual leagues.
But this URL structure doesn’t handle the potential for Manager users to change the date/title of an event which would lead to 404 responses on the original URL.
Obviously each Event has a unique ID that could be used eg.
/events/family/parent/yyyy-mm-dd--the-event-title-slug/123
I could then use .htaccess
to rewrite requests matching this pattern to the actual Event Detail page and use the ID to retreive the Event Details from the databaase. But the ID on the end is still untidy.
Can anyone suggest options to implemet native MODX style Friendly URLs in the same way that would be available if the Events were stored as MODX Resources rather than in the custom database?
Is there a simple way to use existing MODX functions to help?
The function that generates the modx_site_content.alias
entry would be useful to generate the event-title-slug
. Can this be invoked from a
How would you handle this?
Thanks,
Chris