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.
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.
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 ?
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
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:
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’.