Change url appendix

Hi!
I’m building a site that is in Hebrew. Therefore every time a user create a page he needs to add the URL appendix manually, because the titles are always in Hebrew.

I’m wondering if there’s a way to give each page a url automatically - like a number or something (I don’t care for the appearance in the url bar, it can be anything).

I found this thread but it seems that it only lets me take a different input and make it as a slug. But there are no inputs in english in my site.

Any idea how I can achieve this?
:pray:

The slug should be auto-converted from the title? Why do you have to enter them manually?

Have you set the locale for the slug? slugs | Kirby CMS

Thanks! I tried it now. like this:

return [
    'slugs' => 'he'
];

but it’s not working
I thought that maybe because it’s in Hebrew (rtl) it doesn’t work.

and yes - right now I have to enter the url manually because when I write the title of the page in hebrew it doesn’t auto-convert it to url. it keeps it blank.

There doesn’t seem to be a hebrew ruleset for the slug generator: kirby/i18n/rules at main · getkirby/kirby · GitHub

I see now what you mean - Thanks!
I was wondering if there’s a way to give a slug to a page without the field that converts the title automatically - maybe an external code that gives each page a number as a slug ?

You could use the Custom Add fields plugin: Custom Add Fields | Kirby CMS

Thank you!
If I understand correctly - I would then still need the user to fill in a field that will provide the slug. isn’t it?

I found this and here he takes an existing field and use it as a slug - but unfortunately I have no unique fields in english.

You don’t need a field, you can just use the current date and time if you want.

But the plugin already handles this: GitHub - steirico/kirby-plugin-custom-add-fields: Custom fields for Kirby's add dialog.

Thanks!

I added the plugin and also added a file ‘event.php’ inside /site/models that has this code:

<?php
class Event extends Page {
    public static function hookPageCreate($page){
        
                // get value of add field remoteUrl
                $remoteUrl = $page->remoteUrl()->value();

                // fetch remote content
                $content = file_get_contents($remoteUrl);
        
                // update page field content
                $page->update(array(
                    'content' => $content
                ));
        
                // set slug according to add field title
                $page->changeSlug(Str::slug($page->title()->value()));
    }
}

I guess I need to change this code but how?
I tried to change the last line to:

$page->changeSlug(Str::slug($page->date()));

But it didn’t work. now when I try to add an event - after I write the title it just closes the dialog box - it doesn’t take me to the event page at all

I’m clueless and would love know what are the next steps.
Thanks a lot

Don’t know why you would have to add that method, but must admit that I haven’t used the plugin in a while. I’ll try to check it out.

1 Like

Ok, I tested it again. Let’s say you had installed the plugin in a starterkit. Then in the note.yml blueprint you would just add the title field as add-field:

addFields:
  title:
    label: Title
    type: text
    required: true
    icon: title

This will make the create page dialog look like this:

And the page is automatically created with the current timestamp as slug:

Screen Shot 2022-06-09 at 19.57.34

If that’s all you need, you are good to go. No model required.

Thank you so much! - Your’e right, I don’t need the method - it works without it.
Im still having a small problem with that: after I click on ‘create draft’ in the dialog box it just shuts the dialog box but it doesn’t take me to the ‘note page’.

I just see the new draft in the notes list. If I click on it again it opens the note page.
This is how it should work? I would love that it will take me to the note page immediately after clicking on ‘create draft’.

Thank you so much for your super kind help :pray:

1 Like

works!
Thank you so much!
I truly appreciate your amazing help :pray: