Don’t know if it’s a bug of Kirby or a bug of mine, btw here is the problem.
I need to store the visibility status (true/false) on a db, so I’m using the panel.page.sort hook to write the status (and some more fields) to a db table.
When the page goes from invisibile to visibile, it works as expected: the hook code is called and it writes the right value (1) on the table. But when the page goes from visibile back to invisibile, the value on the table remains the same. So, the question is:
- does the hook is called only from invisibile to visibile status? (weird!)
- does the panel.page.sort is the right hook to use?
My code is pretty simple:
kirby()->hook('panel.page.sort', function($page, $oldpage)
{
if($page->template() == "article") saveArticleToDb($page);
});
Right before writing the db, I use a variable to get the $page->isVisible() value:
$isVisibile = ($page->isVisible()) ? 1 : 0;
Any help?
Thank you
Francesco