-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
Unique slugs (next) #501
Comments
Hi, yes you're right the slug functionality is pretty simple. What you can do is to create a custom bootstrap.php in the config folder and hook into Greets, |
Thanks, that's a pretty good solution, I will probably go with that for now. Still, it's not a complete solution for some (edge)cases like if I want two posts with the same title but different slugs. Is that something that you want fixed by a separate slug field that auto generates slugs based on a specified field (like the title) until the slug field is edited (maybe a flag is set slug_field_name_custom = true)? |
create a file <?php
$app->on("collections.save.before.{$collectionname}", function($name, &$entry, $isUpdate) {
// custom code to modify $entry before saving
}); hope this helps. |
Thanks @aheinze but it does not help. I am Front-End guy and have rudimentary php knowledge. |
Correct me if I'm wrong, but wasn't there a "unique" flag for fields in the legacy version of Cockpit? What is the thinking behind removing it? You are right that the hooks are there to do it ourselves, but it does seem like fundamental functionality for a CMS. |
@gryphonmyers there was no unique option, just a slug option for text fields which behaved like in Next |
THAT is where I saw it, I knew I wasn’t crazy!
… On Feb 25, 2017, at 4:47 AM, Piotr ***@***.***> wrote:
I've added a functionality to set flag on slug to be unique within selected collection in previous version here #338 <#338> and here #341 <#341>.
However since PRs have been merged there was no new release.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#501 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFhG2H9Ri3-ADTpVPaHbNB6v1GmUrSyBks5rgCLogaJpZM4LUSNr>.
|
No, you aren't. |
Here's a solution which works fine for me to create slugs automatically: https://gist.github.com/fabianmu/5f73a6c2303e08add4e00dc2e548ef2d In case you create an entry with |
@fabianmu I modified your script with the annotations from Artur and I rewrote it to make it more flexible. https://github.com/raffaelj/cockpit-scripts/blob/master/unique-slugs/bootstrap.php |
As far as I can see, there's no way to enforce an unique slug in cockpit next. This forces us to use URLs such as /news/58541375423d3doc1761310462/my-slug instead of a much more clean /news/my-slug.
What are your thoughts on this? Should we create a separate slug field in addition to the existing {slug: true} option available on text fields, or should we somehow make the slug provided with text fields editable?
The text was updated successfully, but these errors were encountered: