hey… it seems i’m totaly lost…
i made an event page with events as subpages.
works great
now, when i create or update an event, i want to generate an ICS file inside same folder…
so, for testing i tried in config.php:
'hooks' => [
'page.*:after' => function ($event, $page) {
// check if we want to handle the action
if (in_array($event->action(), ['create', 'update']) !== true) {
// no, return early
return;
}
// do something after a page gets created or updated
$hfile = 'test.txt';
F::write($hfile, "testtext");
}
],
how to get the path of the current page where the hook was triggert? i want to store in there, not in root folder
how to get data of fields of this page?
Exception: undefined
Call to a member function root() on null
'hooks' => [
'page.*:after' => function ($event, $page) {
// check if we want to handle the action
if (in_array($event->action(), ['create', 'update']) !== true) {
// no, return early
return;
}
$hfile = "test.txt";
F::write($hfile, $page->root());
}
],
or
'hooks' => [
'page.*:after' => function ($event, $page) {
// check if we want to handle the action
if (in_array($event->action(), ['create', 'update']) !== true) {
// no, return early
return;
}
$hfile = $page->root() . "/test.txt";
F::write($hfile, "testtext");
}
],
if it where that easy… i would not fail =)
$page is available on before hooks… but it seems to be empty on after hooks.
but before does not include latest changes…
Edit: ok… it seems it’s not possible to mix create and update on after hooks…