Toggle visibility and hooks

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 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 is the right hook to use?

My code is pretty simple:

kirby()->hook('', 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


There’s a hook that is called when the page goes from visible to invisible.

Thank you @texnixe! I should have read the documentation with more attention.

But let me say it’s sounds weird to me using two different events for the same thing…

Probably because there are two different methods involved, sort() and hide().