Use friendly URL for AgendaDetail view : possible?

I didn’t found on the documentation the way to use friendly URL to view the Event Detail page, and I don’t know if it’s possible with the current version.
In other words : instead of www.mysupersite.com/detail?event=3 get a www.mysupersite.com/detail/my-super-event-with-nice-keywords

I don’t know if Agenda formally supports that (Jako will surely pitch in soon! :wink: ), but typically you can do things like that using a rewrite without the extra specifically needing to support it.

You’d use something like this, which grabs the first bit of the alias before the - as the ID, and forwards that to the actual detail page. So you’d need a link like www.mysupersite.com/detail/3-my-super-event-with-nice-keywords

Put it before the standard MODX rewrite.

RewriteRule ^detail/(.*)-(.*)$ https://www.mysupersite.com/detail?event=$1

That rule can be optimised further, for example to only check for digits in the first group.

Probably need to generate the link yourself, there’s a useful filterPathSegment output filter available to turn something like a title into an alias suitable for links, so you could do something like this…

<a href="/detail/[[+id]]-[[+event_title:filterPathSegment]]">...</a>

If you want to have a MODX internal routing, you could try the CustomRequest extra. That way, the detail resource alias could be changed, without changing a htaccess rule.

Create a new CustomRequest rule, give it a name, select the detail resource in this rule and set the URI Parameter to ["detail"] ["event"]. After this you could use the following link tag in your code (the detail resource has to be a container):

<a href="[[~<detail_id>]]/[[+id]]/[[+event_title:filterPathSegment]]">...</a>

Thanks you both for yours answers :slight_smile:
I’m trying to implement Jako’s solution but something is wrong.

I have set the Custom Request as you said :

On my tplAgendaRow chunk I have this kind of link :

<a href="[[~19]]/[[+id]]/[[+title:filterPathSegment]]">Link</a>

I’m using [[+title]] instead of [[+event_title]] because this last placeholder is not used on my side (empty value).

On the front end, I have this kind of friendly URL : Évènement - La Claranda
Which is looks good !

But when I follow it, the detail event are not loaded (no event found)

You can have a look on the front end here : https://laclaranda.eu/agenda-friendlyurl
The no-friendlyURL version is here : https://laclaranda.eu/agenda

What did I miss ?

Please use ["event"] as URI Parameter value in CustomRequest.

1 Like

Thanks, it’s working well now :slight_smile: