Geotrek-rando icon indicating copy to clipboard operation
Geotrek-rando copied to clipboard

Unique URL for objects

Open camillemonchicourt opened this issue 8 years ago • 7 comments

We already talked about it for touristic contents and events but sometimes some have the same name. As URL are only based on names, if 21 objects have the same name, they have the same URL and only one of them has a detail page.

Example with Le Chamois that is get twice from our SIT (Apidae) : http://www.grand-tour-ecrins.fr/?categories=C1&search=chamois&C1_type1=66&cities=05153&cities=38073 Only one detail is working : http://www.grand-tour-ecrins.fr/contenu-touristique/le-chamois/

PnCevennes had the same problem with some events that have the same name in their database.

Adding ID (or something else) in URL could be an interesting solution.

If we change detail pages URL we should also think to add a rewriting URL for those that already have their Geotrek-rando V2 online.

camillemonchicourt avatar Aug 16 '17 13:08 camillemonchicourt

The system that got implemented now works as follows:

  • POIs have a URL containing the category slug, a name slug and a new parameter being their unique ID. Example: /rando-vtt/la-cabane-rouge-diois-n3/T1-29196
  • If provided URL (coming from an old bookmark for instance) only contains the category and the name, then the system fallbacks to using the legacy lookup.
  • If provided URL contains a UID that returns no result for some reason, then the system fallbacks to the legacy lookup too.

pacproduct avatar Apr 11 '18 14:04 pacproduct

OK great ! I would rather have done something like /rando-vtt/la-cabane-rouge-diois-n3-T1-29196 or /rando-vtt/T1-29196-la-cabane-rouge-diois-n3/ as this way it looks like it is a sub-page of /rando-vtt/la-cabane-rouge-diois-n3/ but maybe I missed something.

Great too for the fallback. No need for URL rewriting then if I understood.

Thanks.

camillemonchicourt avatar Apr 11 '18 15:04 camillemonchicourt

@camillemonchicourt: No URL rewriting should be needed thanks to the fallback indeed. I get your point about the artificial additional level it visually adds to the URL.

However separating the UID from other parameters with a forward slash provides us with a robust way to retrieve them separately. If we were to concatenate the name slug with the UID, it'd be difficult to be sure where to split the string to separate the UID from the slug.

And even if it would be very unlikely to happen, if we had a place named "T1 326: The great mountain hotel", it would get converted to "t1-326-the-great-mountain-hotel" which would look like a UID followed by a name to the system, although it wouldn't be the case. I think this would make the fallback system way more complex and less efficient too as it would have to try many combinations for looking up the result.

Feel free to open a Pull Request if you can think of a more clever implementation though :)

pacproduct avatar Apr 11 '18 16:04 pacproduct

OK thanks, I understand. Maybe it could have worked to separate with another symbol such as _ or else but I am totally incompetent technically. I couldnt understand the code nor do a PR that's why I really appreciate your explanation and feedbacks. That's great that touristic contents and events now have a unique URL. Maybe we should do the same with treks even if there is less reason that 2 have the same name.

Thanks.

camillemonchicourt avatar Apr 11 '18 18:04 camillemonchicourt

This should affect all results displayed in the sidebar, whether they are treks, events or contents.

pacproduct avatar Apr 12 '18 08:04 pacproduct

OK !

camillemonchicourt avatar Apr 12 '18 08:04 camillemonchicourt

toujours d'actualité

submarcos avatar Jul 25 '18 12:07 submarcos