is it possible to get the content of a page inside a hook before the new content will be overwrite the old one?
From the doc: "Hooks are being triggered after the event is called in the panel."
Some kind of “before update hook” would be great but this is not possible, right?
No, there is no before update hook. While the old page content is or should still available after the hook is triggered, the hook is always triggered after the event. What do you want to do?
Since you always get the old and new page object, you can find out the differences without a problem, you don’t need a pre hook for that. I always wanted to extend my Kirby Logger plugin to save differences to a database, just haven’t got round to it yet.
kirby()->hook('panel.page.update', function ($page, $oldpage) {
// your code
});
Last week i tested the code and it works just fine… but now $page and $oldPage are always the same. No matter what i change in the panel. I’ve no idea how to debug or fix this…
EDIT: it has something to do with the “global-field-definitions” and “Field groups”… i’m still hunting the bug.
EDIT: removed field groups… still the same bug…
Instead of writing to file, you can also use error_log() to write to the PHP error log file.
Apart from that, it works for me, so I guess it has something to do with your particular installation, either Kirby or plugin related. This is the code I’m using:
on the ZendServer here error_log was not working as expected so i used the file approach…anyway:
thx for the double check.
It seems it “just” want work for one module(blueprint)… hmmm
title: Module Hero
icon: cube
pages: false
files: true
fields:
# The title is only used in the Panel for this module
title:
label: Module title
type: text
# The text is used in the module's snippet as $module->text()
text:
label: Text
type: textarea
hheadline:
label: Headline
type: text
coverImage:
label: Cover Image
type: image
minheight:
label: minimale Höhe in Zeilen
type: text
imgath:
label: Attach horizontal
type: select
width: 1/2
options:
left: Left
center: Center
right: Right
imgatv:
label: Attach vertical
type: select
width: 1/2
options:
top: Top
center: Center
bottom: Bottom
auditline:
type: headline
label:
de: Freigabe
en: Approval
auditpending:
label: audit pending
type: text #hidden
default: ''
auditedby:
label: auditedby
type: text #hidden
default: ''
audit:
label: Geprüft
type: audit
text: This is just a test
“hheadline” was between “title” and “text” and the name was “headline”… but changes doesn’t help.
I deleted the content txt file and now, after refilling the page in the panel, it works!? Even with a field called “Headline”… thought it is a reserved word but it seems not.
@bvdputte: yes, image field and two languages… … . gnmpf