kirby-modules
kirby-modules copied to clipboard
Hook cache issue
Hi man,
Great stuff ! Having an issue, I´m trying to update the field with a hook. The hook works and are updating the text file accordingly, but when I visit the page with the updated field, nothing is shown, although the text file are updated. If i hit save on the page, it deletes the updated field entry from the hook function. If I don´t hit save and clear my cache the page displays the field accordingly..
Text file :
Griddy:
-
title: ""
subtitle: ""
type: pager
options:
name: North face
uid: north-face
uri: projects/north-face
parent: projects
-
title: ""
subtitle: ""
type: pager
options:
name: Billabong
uid: billabong
uri: projects/billabong
parent: projects
Hook file:
kirby()->hook('panel.page.create', function($page) {
$parent = $page->parent();
if ($parent->depth() > 0) {
$griddy = $parent->griddy();
if ($griddy) {
$griddy = $griddy->yaml();
$griddy[] = [
'title' => "",
'subtitle' => "",
'type' => 'pager',
'options' => array (
'name' => (string)$page->title(),
'uid' => (string)$page->uid(),
'uri' => (string)$page->uri(),
'parent' => (string)$parent->uri()
)
];
$parent->update([ 'griddy' => yaml::encode($griddy) ]);
}
}
});
Hi,
Unfortunately (last time I looked – before 2.3 was released) there was no way for this plugin to hook into when the page cache clears due to the file being modified.
Until there's a hook available this can't be fixed without modifying Kirby's core.
Oh well, thanks man !!