# Custom panel view

**URL:** <https://forum.getkirby.com/t/custom-panel-view/30003>\
**Category:** Questions\
**Tags:** v4\
**Created:** [November 15, 2023, 11:11am UTC](https://forum.getkirby.com/t/custom-panel-view/30003 "2023-11-15T11:11:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_Jones](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gareth_jones/32/9981_2.png) [@Gareth\_Jones](https://forum.getkirby.com/u/Gareth_Jones)\
**Post date:** [November 15, 2023, 11:11am UTC](https://forum.getkirby.com/t/custom-panel-view/30003/1 "2023-11-15T11:11:46Z")

</div>

I have a simple custom panel area that adds a “settings” button to the left hand menu. It works fine, but the active state does not getting added when the page loads, is there a way to do this?

```auto
<?php

Kirby::plugin('kit/settings-panel-button', [
    'areas' => [
        'settingsarea' => function ($kirby) {
            return [
                'label' => 'Settings',
                'icon' => 'cog',
                'menu' => true,
                'link' => $kirby->url('panel') . '/pages/settings',
                'views' => [
                    [
                        'pattern' => 'pages/settings',
                        'action' => function () use ($kirby) {
                            return [
                                'component' => 'k-page-view',
                                'props' => [
                                    'page' => $kirby->page('settings')
                                ]
                            ];
                        }
                    ],
                   
                ],
                
            ];
        }
    ],

]);

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 15, 2023, 7:06pm UTC](https://forum.getkirby.com/t/custom-panel-view/30003/2 "2023-11-15T19:06:20Z")

</div>

Problem is that everything under `pages` always has the `site` active. You have two options:

1. Don’t create it in the `pages` namespace, but for example

```auto
'link' => $kirby->url('panel') . '/tools/settings',
// ...
    'pattern' => 'tools/settings',

```

Or create a custom menu and redefine how `site` via other pages in the `pages` namespace behave.

---

<div class="post-metadata">

**Author:** ![Gareth\_Jones](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gareth_jones/32/9981_2.png) [@Gareth\_Jones](https://forum.getkirby.com/u/Gareth_Jones)\
**Post date:** [November 15, 2023, 7:47pm UTC](https://forum.getkirby.com/t/custom-panel-view/30003/3 "2023-11-15T19:47:08Z")

</div>

thanks, I need to use ‘/pages/settings’ as I want to use a blueprint for the settings (unless this is still possible?)

I got very close using the current param, but the dashboard also becomes active, when you click settings.

```auto
Kirby::plugin('kit/settings-panel-button', [
    'areas' => [
        'settingsarea' => function ($kirby) {
            // Get the current URL
            $currentUrl = $kirby->request()->url()->toString();
            $settingsUrl = $kirby->url('panel') . '/pages/settings';
            $isCurrent = $currentUrl === $settingsUrl;

            return [
                'label' => 'Settings',
                'icon' => 'cog',
                'menu' => true,
                'current' => $isCurrent,
                'link' => $settingsUrl,
                'views' => [
                    [
                        'pattern' => 'pages/settings',
                        'action' => function () use ($kirby) {
                            return [
                                'component' => 'k-page-view',
                                'props' => [
                                    'page' => $kirby->page('settings')
                                ]
                            ];
                        }
                    ],
                ],
            ];
        }
    ],
]);

```

There is a menu class here, that does work great: [GitHub - tobimori/kirby-spielzeug: 🧸 The helping hand for my Kirby Baukasten starterkit](https://github.com/tobimori/kirby-spielzeug)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 15, 2023, 7:55pm UTC](https://forum.getkirby.com/t/custom-panel-view/30003/4 "2023-11-15T19:55:25Z")

</div>

Hm, in that case you don’t really need a custom view but could just use a link to a page? Would be the same problem, though. See

> [@Create a link in side navigation](https://forum.getkirby.com/t/create-a-link-in-side-navigation/29898/2):
>
> You can do that via the panel.menu option: \<?php use Kirby\Cms\App; return ['debug' =\> true, 'panel' =\> ['menu' =\> [ 'site', 'system', 'users', '-', 'about' =\> [ 'icon' =\> 'pen', 'label' =\> 'About', 'link' =\> 'pages/about', 'current' =\> function (): bool { $path = App::instance()-\>request()-\>path()-\>toString(); return Str::contains($path, 'pages/about'); },], ], ], ]; There seems to be something not quite working as expeacted,…

---

<div class="post-metadata">

**Author:** ![Gareth\_Jones](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gareth_jones/32/9981_2.png) [@Gareth\_Jones](https://forum.getkirby.com/u/Gareth_Jones)\
**Post date:** [November 15, 2023, 8:00pm UTC](https://forum.getkirby.com/t/custom-panel-view/30003/5 "2023-11-15T20:00:44Z")

</div>

oh great! that looks like it will work for me.
