Safe way to get the panel url?

http://getkirby.com/docs/cheatsheet#urls

With Kirby 2.2 the panel url is optional. How do I get the panel url by PHP?

Unfortunately you can’t. The Kirby core doesn’t know where you moved your Panel folder to, because the Panel is completely independent from the core.

I recommend using a custom config option for this so that you can easily change the URL without having to change it in all of your templates.

1 Like

Thanks! I wanted to know because I’m building a plugin and I’m trying to have as few options as possible. I guess I don’t get rid of this option then.

For my Notifier Plugin I wrote a PHP-function that got the active URI-scheme for the panel.

The output was matched to the folder-preference in the config-file, so the plugin “knew” the panel-dir was active…

config.php


function activeDIR($url)
  {
substr($url,-1) != '/'?$url.= '/':$url = $url;
$path = parse_url($url, PHP_URL_PATH);
$pathTrimmed = trim($path, '/');
$pathTokens = explode('/', $pathTrimmed);

  if (substr($path, -1) !== '/')
    {
  array_pop($pathTokens);
    }

return end($pathTokens);
  }

if(c::get('kirbyNotifierPanel') == activeDIR($_SERVER['REQUEST_URI']))
{
/* panel is active */
}