phpkirby

site.php conflict for panel in Kirby CMS


Kirby CMS supports a non default file structure. http://getkirby.com/docs/advanced/customized-folder-setup

When I introduce the following content to the site.php file:

// changing the directory
$kirby->roots->content = $kirby->roots()->index() . DS . 'vendor/client-content';

// changing the url
$kirby->urls->content = $kirby->urls()->index() . '/client/mindfulness-content';

The panel redirects to panel\panel\install or panel\panel\login which does not exist because it is has an unnecessary redirect. However This is pretty much exactly copy and pasted from the docs.

If I try panel\install or panel\login it doesn't try and redirect but styles are not loaded.

If attempt to logon it produces a 'Invalid route' exception:

/panel/app/panel.php:203 Stack trace: #0 /panel/index.php(47): Panel->launch() #1 {main} thrown in /panel/app/panel.php on line 203

If I leave site.php with only the following it is perfectly happy:

<?php 
$kirby = kirby();

I'm running the following php on apache:

PHP 5.4.16 (cli) (built: Oct 31 2014 12:59:36) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

This problem has been reported for Ngnx too https://github.com/getkirby/panel/issues/287

Reasons for this folder structure:

In this case I wanted to load content from another git repo using composer. This give made my deployment process easier to manage from cli and lets the content maintainer proceed independently.


Solution

  • This is a bug with the current version of Kirby. It has a very simple fix supplied by Kirby's creator @bastianallgeier

    The following variable needs be defined for the panel to work.

    $kirby->urls->index 
    

    If there are a variety of domains and sub-domains to work with the following snippet added to the site.php works great.

    <?php
    
    $kirby = kirby();
    
    switch(url::host()) {
      case 'example-a.com':
    
         $kirby->urls->index = 'http://example-a.com';
    
         …
    
         break;
     case 'example-b.com':
    
         $kirby->urls->index = 'http://example-b.com';
    
         …
    
         break;
     case 'sub.example-b.com':
    
         $kirby->urls->index = 'http://sub.example-b.com';
    
         …
    
         break;
    }