How to open a custom fiber dialog via PHP?

(Note: initially posted here in Discord)

How to open a custom fiber dialog from PHP (e.g. in a hook callback function)?

I’ve tried

$dialogUrl = $page->panel()->url() . '/myCustomDialog';

// Example value of $dialogUrl: "http://127.0.0.1:8080/panel/pages/blog+test-post/myCustomDialog"

return Panel::go($dialogUrl);

Where the relevant dialog code is:

'dialogs' => [
   'page.myCustomDialog' => [
      'pattern' => 'pages/(:any)/myCustomDialog',
      'load' => function (string $path) use ($kirby) {
         // custom dialog code here...
      },
   // ...

But that returns

The view could not be found

I’ve tried a number of other possible paths but always get the same error.

Is using Panel::go($dialogUrl) here the correct approach?

If so, any ideas as to why the path isn’t working?

Otherwise, what’s the correct approach for this?

You cannot open a dialog in the Panel from a backend/PHP hook.

Oh, ok. Totally missed that. Important to know! Thank you!