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

[Data Object] Custom URL-Slug for Data Objects #5575

Open
brusch opened this issue Jan 13, 2020 · 11 comments
Open

[Data Object] Custom URL-Slug for Data Objects #5575

brusch opened this issue Jan 13, 2020 · 11 comments

Comments

@brusch
Copy link
Member

@brusch brusch commented Jan 13, 2020

URL-Slug Data-Type

  • basically like the input data-type
  • client-side regex validation for valid URL path-info (starting with a /)
  • server-side validation against existing document URLs (incl. pretty URLs) and object URLs
  • storage is a central object_url_slugs table (needed for lookup)
  • support for localized fields
  • support for sites
  • in config: controller/action to be called (incl. services) e.g. AppBundle\Controller\NewsController::detailAction

Router for Object URL Slugs

See also:
https://symfony.com/doc/current/routing/routing_from_database.html
and
existing Pimcore implementation for dynamic routing used by documents:
https://github.com/pimcore/pimcore/blob/4c986d60d890898e466533a21dfd29bde2acb9f6/lib/Routing/DynamicRouteProvider.php
https://github.com/pimcore/pimcore/blob/947e4b62e48610bb71615e39d937a3e67287258f/lib/Routing/Dynamic/DocumentRouteHandler.php
...

  • the context should be available on the request, like, object, fieldname, locale (if within LF), ...
@solverat

This comment has been minimized.

Copy link
Contributor

@solverat solverat commented Jan 13, 2020

@brusch! YES! Also consider some uniqueness, so we could get rid of ids in URLs for example.

  • instead of news/my-entry-12 it should be possible to fetch news/my-entry
  • but also blog/my-entry should be possible

Maybe there should be a "regex unique validation" per route? Available in a pre-save event?

@solverat

This comment has been minimized.

Copy link
Contributor

@solverat solverat commented Jan 13, 2020

second thought: if there is a lookup table and the full path will be stored, a unique key for path on db side should be enough?

@dpfaffenbauer

This comment has been minimized.

Copy link
Contributor

@dpfaffenbauer dpfaffenbauer commented Jan 13, 2020

Also: One object could have multiple routes!

@brusch

This comment has been minimized.

Copy link
Member Author

@brusch brusch commented Jan 13, 2020

@solverat of course, see

server-side validation against existing document URLs (incl. pretty URLs) and object URLs

@dpfaffenbauer that's why I think a data-type is the best solution, you can then do whatever you want

@dpfaffenbauer

This comment has been minimized.

Copy link
Contributor

@dpfaffenbauer dpfaffenbauer commented Jan 13, 2020

so the data-type value gets stored into a central table?

@brusch

This comment has been minimized.

Copy link
Member Author

@brusch brusch commented Jan 13, 2020

Yes, at least this was my first idea 😉
In my opinion this would make sense, otherwise the lookup for routing and validation would be very complicated and slow. Since every data-type can decide on it's own how it get's saved, this should be also the easiest solution. Do you have any concerns about that?

@solverat

This comment has been minimized.

Copy link
Contributor

@solverat solverat commented Jan 13, 2020

There is already the object table. Extend it with a „slug“ row could do the job?

Edit: no, there could be more than one per object (locale, multisite)

@brusch brusch added the Prio-Backlog label Jan 14, 2020
@dpfaffenbauer

This comment has been minimized.

Copy link
Contributor

@dpfaffenbauer dpfaffenbauer commented Jan 14, 2020

@solverat still could work, if it is a data-type, it just persists itself into the object table. But, I think having a separate table for it will make it work faster, since you can have special indicies for querying that table.

@brusch no, not at all. Also think about multi-site here. With Static Routes I have the possibility to let a route only resolve for a certain site. It should also be possible to use the slug type within localized fields, so one entry for every language then.

@brusch

This comment has been minimized.

Copy link
Member Author

@brusch brusch commented Jan 14, 2020

@dpfaffenbauer sure, see above.

support for localized fields

Multi-site: good point! 👍(added to the list above)

@markus-moser

This comment has been minimized.

Copy link
Contributor

@markus-moser markus-moser commented Jan 14, 2020

Maybe we could think about creating (301) redirects when the slug changes too?

@brusch

This comment has been minimized.

Copy link
Member Author

@brusch brusch commented Jan 14, 2020

Yep, but in a later stage :)

@brusch brusch added this to To do in #76 | 07/01/2020 - 17/01/2020 via automation Jan 15, 2020
@brusch brusch added this to To do in #77 | 20/01/2020 - 31/01/2020 via automation Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.