How to get the panel edit page subpage url?

Hello,

I have built a front-end private backend in which a connected user can see some sub-pages.
I would like to allow the admin user to click on a sub-pages title to open and edit it in the kirby panel.

What is the easy way to generate the subpages link to open it in the edit panel page?

Something like:

<a href="http://my-domaine.com/panel/pages/my-page/my-subpage/edit">subpages title</a>

I suppose something like this could do the job:

<a href="<?= $site->url() ?>/panel/pages/<?= $page->find('subpage-uri')->uid() ?>/edit">subpages title</a>

… but some part of this url is hardcoded (/panel/pages/ & /edit). Is there a Kirby function to get this panel url ?

There’s the purl() helper function but it’s only available when the panel is loaded. Wouldn’t work in your case.

I would create a custom page method based on the purl() code. This way it could be used like so:

$page->find('subpage-uri')->panelUrl()

Thanks @pedroborges for your advices. I will check how to create a custom page method out :slight_smile:

@gillesvauvarin:

You can look at https://forum.getkirby.com/t/howto-working-with-contextual-links-to-the-panel/1566/7 or the whole solution on that page. The pictures there are from the old Starterkit https://github.com/getkirby/starterkit/releases/tag/2.3.2!

May be, you have to adjust my code to your needs.

Good luck!