Some of my clients use ftp to upload their files because of the php upload limit on their server.
my uploaded files that are hidden in the panel ( because of spaces ) are not renamed, when triggering this hook.
What can it be?
'some hook' => function ($page) {
foreach (page()->files() as $file ) {
try {
$file->changeName(F::safeName($file));
} catch (Exception $e) {
echo $e->getMessage();
}
}
},
What sort of hook is that? A custom hook?
tested it with ‘page.changeTitle:after’, not sure what the best hooks are for it. It will be
page.changeStatus:after, page.update:after
i think.
'hooks' => [
'page.changeTitle:after' => function ($newPage, $oldPage) {
foreach ($newPage->files() as $file ) {
try {
$file->changeName(F::safeName($file));
} catch (Exception $e) {
echo $e->getMessage(); // this is useless in a hook, you could try and throw an exception
}
}
}
]
But then you have to trigger those hooks somehow by changing the page title or whatever.
Hello Sonja,
This will work perfectly for my clients. Thx!!
'hooks' => [
'page.update:after' => function ($newPage, $oldPage) {
foreach ($newPage->files() as $file ) {
$file->changeName(F::safeName($file->name()))->update([
'template' => $file->type()
]);
}
},
]