Link to panel page from front end

You can outsource the link code into a field method. Useful if you need such a link in multiple locations:

  1. Create a field method in a plugin:
Kirby::plugin('my/methods', [
    'fieldMethods' => [
      'editLink' => function($field) {
          $page = $field->parent();
          $title = $page->title();
          if (kirby()->user()) {
            $title .= ' ' . Html::a($page->panelUrl(), 'Edit page', ['class' => 'editlink']);
          return $title;
  1. Then in your template where needed
<h1><?= $page->title()->editLink() ?></h1>

Adapt as needed to show only an edit icon (with accessible text) or add more checks (e.g. for user permissions), use another field etc…

1 Like