I have the following Model / After Page Create Hook:
class DarbietungPage extends Page {
public static function hookPageCreate($page){
$customSlug = $page->title()->lower() .'-'. $page->date()->toDate( '%d-%m-%Y' ); // pagetitle-2022-03-02
// do something before a page gets deleted
$page->changeSlug(Str::slug($customSlug));
}
}
blueprint:
addFields:
title:
label: Titel
type: text
required: true
icon: title
preselect: true
date:
label: Datum
help: Wann findet die Darbietung statt?
type: date
display: DD.MM.YYYY
default: today
required: true
__dialog:
skip: false
redirect: true
But when i set redirect: true it tries to redirect me to darbietungen-TIMSTAMP (timestamp is default, when no slug field is there, i know)
But how can i set the slug or redirect to a dynamic value like the title and date?
According to this https://github.com/steirico/kirby-plugin-custom-add-fields/tree/master#configure-redirects i can somehow set the redirection.
I have the following Model / After Page Create Hook:
blueprint:
But when i set
redirect: true
it tries to redirect me todarbietungen-TIMSTAMP
(timestamp is default, when no slug field is there, i know)But how can i set the
slug
orredirect
to a dynamic value like the title and date?Kinda related to #57