Display alert notification in Kirby 3 panel

Similar to the K2 question, but is it possible in K3? I’m updating to K3 and would like to continue to alert the user when they run the page.update:after hook. Thanks for any info.

1 Like

Did you ever resolve this @lukehatfield ?

no @parislettau, I couldn’t get panel()->notify($message) to work again :disappointed_relieved:

Hi @lukehatfield and @parislettau ,

With Kirby 3, you can use an Exception to display a modal in the panel with your alert message.

Example: (/site/config/config.php)

return [
    'hooks' => [
        'page.update:after' => function ($newPage, $oldPage) {
            if ( $newPage->title() !== $oldPage->title()  ) :
                throw new Exception( 'Hey, you have changed the title! );
            endif;
        }
    ]
]

Another solution would be to use the K3-WhenQuery plugin to display an alert info field under certain conditions GitHub - rasteiner/k3-whenquery: Conditionally show fields and sections. Better.

1 Like