Panel hook issues?

Hi,

Is that me or some panels hooks have issues since the last update?

If I add to my site/config/config.php file:

kirby()->hook('panel.page.create', function($page) {
  f::write( kirby()->roots()->content() . '/test-create.txt' , $page->title() . "\n", true);
});
kirby()->hook('panel.page.update', function($page) {
  f::write( kirby()->roots()->content() . '/test-update.txt' , $page->title() . "\n", true);
});
kirby()->hook('panel.page.delete', function($page) {
  f::write( kirby()->roots()->content() . '/test-delete.txt' , $page->title() . "\n", true);
});
kirby()->hook('panel.page.sort', function($page) {
  f::write( kirby()->roots()->content() . '/test-sort.txt' , $page->title() . "\n", true);
});
kirby()->hook('panel.page.hide', function($page) {
  f::write( kirby()->roots()->content() . '/test-hide.txt' , $page->title() . "\n", true);
});
kirby()->hook('panel.page.move', function($page) {
  f::write( kirby()->roots()->content() . '/test-move.txt' , $page->title() . "\n", true);
});

Create, delete, hide and sort gives something not the other.
Clue?

Thanks,
j.

I’m afraid I don’t understand what exactly is the issue? Can you explain a bit more?

I tested it with a Kirby 2.2.3 install and seems to work as expected?

Thank you for your answer.

I will try to describe what I tested and what worked or not:

With the code above in my site/config/config.php.
If I wrote it correctly, it should create a test-*.txt file in the content folder depending on actions from the panel.

My Process:

  • when I create a new page in the panel, test-create.txt is writing: OK
  • when I update content of a hidden page in the panel, test-update.txt is writing: OK
  • when I update content of a visible page in the panel, test-sort.txt is writing, but not test-update.txt: Not OK, should not be just panel.page.update (or panel.page.update + panel.page.sort if you change content and position)?
  • when I sort a page in the panel, test-sort.txt is write: OK
  • and I don’t know what «panel.page.move» could mean from the panel, so I not able to test it.

Thank you for taking time to read my ugly english.

This triggers when you rename the page slug with the panel option “Change URL”.

Yes, you are right. On updating, when the page is invisible, panel.page.update is triggered, when the page is visible, panel.page.sort is triggered instead of panel.page.update.

I have created an issue on GitHub: Panel.page.update is not triggered when updating a visible page · Issue #701 · getkirby-v2/panel · GitHub

1 Like

Piggybacking on this, there also seems to be an issue with the ‘panel.file.upload’ and ‘panel.file.update’ hooks. When panel.file.update is set, panel.file.upload doesn’t get triggered.

In one plugin, for panel.file.upload, we would grab some data from an uploaded CSV/JSON, update the page, and delete the file. In another plugin, the panel.file.update hook would rename an updated file under certain circumstances. This caused the upload hook to not work. We tried bringing the update hook into the same file, and putting it both before and after the upload hook, and the upload hook only worked when the update hook was removed entirely.

Are the multiple hooks on files not intended to work sequentially like we’re trying to do? Or is there a cache somewhere that should be getting reset between those hooks getting triggered?