Closed junnotantra closed 5 years ago
Just a thought, but might want the slug edit to be implicit by adding a editable field for edit view only.
Just a thought, but might want the slug edit to be implicit by adding a editable field for edit view only.
it would be wonderful to have this feature
When I get a little time this weekend I'll look at doing a PR for that. Something similar to how WordPress managed permalink changes.
Btw, just tried a stupid thing. I edited the DOM from my browser inspector.
Removed the disabled="true"
from
<input value="what-the-slug-is-this" label="URL Slug" type="text" disabled="true" placeholder="Will be set automatically" name="slug">
Then save, it works. :+1:
Not sure if it's expected or not
That might be all you need. I'll still take swat at it. Just remove the style. Adding a button that makes that field editable might be a good idea. I want to check for unwanted words, like "the, a, and. . . ." since Google Search ignores them. But not sure if that's what every user wants.
Found out, it doesn't work as expected.
I cannot retrieve the item using the forcefully edited slug.
/api/content?slug=what-the-slug-is-this
returns error
while I can retrieve the item using the original slug
/api/content?slug=what-the-slug
returns
{
"data": [
{
"uuid": "eeb0b6ed-ddda-4738-adae-7a3c8ef5d653",
"id": 4,
"slug": "what-the-slug-is-this",
"timestamp": 1558083709000,
"updated": 1558162849040,
"title": "what the slug is this",
"content": "update pls<br>",
}
]
}
still need help to update slug and make the item retrievable by the edited slug thanks in advance
Will do and update here.
if you override the item's implementation of sluggable
you can get very close I think, the catch being that you need to save twice, which is less than ideal.
// provide custom slug here
func (a *Article) ItemSlug() string {
return strings.Replace(a.Title, " ", "-", -1)
}
Hi guys, I've opened a PR for this issue. If you have time, please take a look at #309 Thank you
Hi, I'm able to customize my slug by overriding
String()
When I make an item with title
what the slug
, the slug will bewhat-the-slug
But this only happen when the item was first created. When I edit the title to be
what the slug is this
, I want the slug to change towhat-the-slug-is-this
instead of keeping the original slugwhat-the-slug
. Is this possible?I've tried to update the slug on
BeforeSave()
but changing the slug there not work as expected.Btw, thanks for the awesome CMS :+1: