Get panel edit URL for entry

I’m trying to build a context menu in the frontend, with a link to edit the current page in the panel. How can I get the URL to the panel edit form for a given Page object? I’m looking for something like $page->editUrl() or $page->panelUrl(), but can’t find anything. I’ve also checked the Panel class, but it doesn’t have a method for that either.

Also, how do you get panel URLs in general? For example, I want to show links to:

  • The dashboard.
  • The users list.
  • The system overview.
  • The current user’s profile.
  • The logout URL.
  • The current user’s profile

In previous versions used to be $page->panelUrl() but is now $page->panel()->url() (not quite sure when that changed, but some versions ago)

Same panel object exists for the site and user objects:

Here’s you can find the panel object

3 Likes

@texnixe Thank you! I’ve figured out most of the other routes as well, I’ll leave that here in case anyone else is looking for this:

use Kirby\Panel\Panel;

$urls = [
    // panel
    $kirby->url('panel'),

    // site dashboard
    $site->panel()->url(),

    // page edit form
    $page->panel()->url(),

    // user profile
    $kirby->user()->panel()->url(),

    // users list
    Panel::url('users'),

    // logout
    Panel::url('logout'),
];

Not sure about the last two, though. Is the Panel::url() method the only way to get those URLs relative to the panel’s slug? Is there a cleaner way to access those routes and get their URL?