I have a working hook, that populates a field βdateβ with the title, which is a date-string in the format yyyy-mm-dd and replaces the title with a formatted date:
kirby()->hook('panel.page.create', function ($page) {
if ($page->intendedTemplate() === 'date') {
$format = l::get('date-title-format', 'Market in {city} on %d. %B %Y'); // expectedly not working
$format = str::template($format, [
'city' => $page->parent()->title()->value()
]);
$title = $page->date($format, 'title');
$uri = str::slug($title);
if (! $page->parent()->find($uri)) {
$page->update([
'date' => $page->title()->value(),
'title' => $title
]);
$page->move($uri);
}
}
});
However l::get
does not work β and I understand why. But I was wondering how I would change the format for each language? How do hooks work in multilanguage situations?