Sorry, we don't support your browser.  Install a modern browser

Push notification to panel via PHP

It would be really helpful for plugin developers to have an option to push a notification to the panel using PHP. Think of the need to communicate state to the user, e. g. the mode of the site (“This site is currently in maintenance mode”) or of the plugin itself (“Plugin XYZ is unregistered. Please add a license.”). Right now this requires you to register a custom JavaScript to do this and it can be very cumbersome if your plugin does anything but nothing on the JS end.

It doesn’t have to be anything fancy for now. Something simple like setting a message and a theme on a core object, e. g. $kirby->panel->notification($message, $theme). There isn’t even a need to handle multiple notifications right now because the panel is only able to display a single one currently. Having the option to set HTML in the message would be helpful to display links.

a year ago

Related if multiple notifications would be interesting in the long run: https://kirby.nolt.io/639

a year ago

PS: I know you can push a notification by throwing an exception in a hook but that only works if an action is processed, like updating a page or similar not on panel load. Also, as this is an exception, it will always be themed as an error which is not what you might want.

a year ago

Writing down somet thoughts regarding a possible implementation that we had during the plugin developer office hour:

  • a method to register notfications, e.g. $kirby->panel()->notification()
  • a stack in a new Panel\ object collecting the notifications
  • on any Fiber response, we dump that stack of notifications to the Panel to display

Open question: is Fiber communication frequently enough happening for this to feel like a good experience?

This definitely also would need stacked notficiations to be supported: https://feedback.getkirby.com/639

9 months ago