How to edit current page link with URLkey

I have made a link in the front-end of the website to get easy access to the panel and the current page. And it works great as long there is no URL-key involved. Is there a way I construct the link to edit the current page in the panel with a URL-key and also make sure the language in selected in the panel is correct?

My current link:

<a href="<?php echo url('panel/pages/' . $page->uri() . '/edit') ?>" target="_blank">EDIT CONTENT</a>

The uri() method accept a $lang parameter. It should then return the translated URI:

1 Like

Thank you @texnixe! As always you are so quick. Thank you. :smile:

Even after passing the language, I get “Page not found” in the panel. Since the page “root” url is still the none URL-key one for the panel. So this turned out to be much harder. Is there a way to get the none URL-key url and add in the language to make the link for the other languages?

Than I can make if base language do this, and if not do that. If you follow me on the idea?

A, the problem is that you have to add the language, this is how the urls look in a multi-lang installation, I currently have no access to a multi-site with URL keys, so please check what the URLs should actually look like


Does the Panel even use the URL-keys? If not, you can just use the uri() without the language code and add the query string.

No the panel do not use URL-keys. But query string worked perfectly. So for everyone that comes after. Here is my final solution:

<a href="<?php echo url('panel/pages/' . $page->uri('de') . '/edit?_language=' . $site->language()) ?>" target="_blank">EDIT CONTENT</a>