1 Panel for multiple websites

Hi,

Is it possible to have a single universal Panel for multiple Kirby installations?
I have 3 websites hosted on a single VPS. Each with their own nginx server block and domain.

It would be nice to have a single Panel where our editor can add content to the three websites using just 1 panel. Tabs to separate the inputs may be.

What you could do is to setup a multisite setup, but with a few little modifications (because by default the setup will still have a Panel for each site):

  • Disable the Panel in the config files of the individual sites with the panel option.
  • Instead of having one parent directory per site, put the content into subfolders of just one folder:
    index.php
    content/
      site.txt
      my-site/
        site.txt
        ...
      my-other-site/
        site.txt
        ...
      my-shop/
        site.txt
        ...
    
  • Setup a fourth site in the multisite setup that receives the whole content directory as input. This site will then be used for the Panel.

This setup has one limitation though: As you can see in the directory tree above, the blueprint site is used both for the “outer” site as well as for the individual sites. There is no way to get around that, so you won’t be able to differentiate between the two levels and even the three different sites in the site blueprint. So you will need to keep that one blueprint simple (just a single pages section with all subpages for example).

Besides that, it should work pretty well actually (but I haven’t tested this particular setup yet).

1 Like

Hi @lukasbestle, et. al. – pardon me for resurrecting an old thread, but it’s relevant to my situation…

Using clues from this and a few other threads, I’ve gotten a multisite running with only content separated. Accounts and sessions are shared, but each site has its own panel. (Setup shown below.)

I’m not sure how to get from here to “one panel,” and I think it’s down to my limited PHP skills.

  1. With my site/config/config.php shared, I can’t disable the panel of the individual sites. In addition to the individual content folders, should I be using individual config folders – content/siteone/config/config.php and content/sitetwo/config/config.php? I’m not sure how to set up different routing in index.php for the “outer” site vs. the individual sites. (And I wouldn’t actually care if those panels were disabled or not, as long as a master panel was accessible.)

  2. How would I achieve “Setup a [third] site in the multisite setup that receives the whole content directory as input. This site will then be used for the Panel.” I presume this would be my “base” site, but, likewise, I don’t know how to direct that root alone to receive all of /content in index.php.

I wonder if you could tell me if I’m on the wrong track with this setup, or if you could suggest a way forward…?

<?php
require 'kirby/bootstrap.php';

$sites = [
  'multisite.com' => __DIR__,
  'siteone.com' => 'siteone',
  'sitetwo.com' => 'sitetwo',
];

$host = Url::host();
$root = $sites[$host];
$url  = 'http://' . $host;

$kirby = new Kirby([
  'roots' => [
    'index'   => __DIR__,
    'site'    => __DIR__ . '/site',
    'content' => __DIR__ . '/content' . '/' . $root,
    'media'   => __DIR__ . '/media',
    'assets'  => __DIR__ . '/assets'
  ],
  'urls' => [
    'media'  => $url . '/media',
    'assets' => $url . '/assets',
  ],
]);

echo $kirby->render();

Let’s suppose you leave the structure as is, the multisite would be the host for your Panel. But you would have to define the root for the content conditionally.

$content = ($host === 'multisite.com') ? __DIR__ . '/content' : __DIR__ . '/content' . '/' . $root;

$kirby = new Kirby([
	'roots' => [
		'index'   => __DIR__,
		'site'    => __DIR__ . '/site',
		'content' => $content,
		'media'   => __DIR__ . '/media',
		'assets'  => __DIR__ . '/assets'

	],
	'urls' => [
		'media'  => $url . '/media',
		'assets' => $url . '/assets',
	],
]);

You would then set up a site.yml similar to this:

sections:
  siteone:
    type: pages
    parent: site.find('siteone')
  sitetwo:
    type: pages
    parent: site.find('sitetwo')

All the other blueprints would then have to be set up to keep in mind that the content now belongs to multisite.com (i.e. when fetching parent pages etc.)

If you really only need one config file, you could set the Panel to true/false conditionally:

'panel' => Url::host() === 'multisite.com',

Ah, brilliant – thank you so much! I made your changes verbatim, and everything worked on my test site(s) as expected. To avoid actually needing a third domain, I further changed multisite.com to admin.siteone.com in both index.php and site.yml, and that’s working too.

The only issue, thus far, happens when I implement the Enhanced Toolbar Link Dialog plugin (a requirement.) It of course uses the full path to each content page, and builds invalid links which include that subdirectory: http://siteone.com/siteone/careers/admin-assistant

I’ve tried doing some str_replace in site\plugins\enhanced-toolbar-link-dialog\routes.php :

@ line 7:

function pageUrl(Kirby\Cms\Page $page, bool $qualified)
{
    if ($qualified) {
        $url = $page->url();
    } else {
        $url = parse_url($page->url(), PHP_URL_PATH);
    }
    
    $url = str_replace(['siteone/', 'sitetwo/'], '', $url);
    
    return $url;
}

@ line 89:

if ($page) {
    $data = customPageData($page);
    $data['link'] = str_replace(['siteone/', 'sitetwo/'], '', $data['link']);
    return $data;
}

… but this has had no effect on the links presented in the link dialog.

I realize this plugin is not Kirby core, but maybe you (or @gearsdigital) would have an idea whether I’m on the right track or not? I didn’t imagine a way to accomplish this outside of the plugin…

Thank you very much for using my plugin @toddz!

routes.php isn’t the location where links are created. This happens within the Vue part of the plugin.

I can’t say much regarding multi languges setups because I haven’t yet worked with it. But are you aware that you can configure a url.

If I understand above mentioned documentation correctly you should be able to configure it by setting url to / in your site config.

// /site/config/config.php
return [
  'url' => '/'
];

Maybe this does the trick? But to be honest I haven’t read the whole thread so I may not fully understand your issue ^^

I doubt that setting the url will help in this case, because it’s about the path to the page (and actually also to files when dragging and dropping them). And from the perspective of the admin site, the paths are correct, but wrong from the perspective of the actual sites.

Not sure how to work around this issue.

You’d probably need a page model that modifies the page ids (for selecting the right pages) and then make sure that the UUID is stored instead of an id to make sure the right page is later displayed.

I think using two Panels would be the better option here, those Panels could store the same credentials to make switching easier.

Thanks for the reply, @gearsdigital. The issue is my multisite setup has Kirby internally fudging paths to the content for two separate sites under one panel, but the plugin builds links using the actual physical file paths, which won’t end up working. I lack the chops to mess around with Vue, so I may have to go back to two panels. I think that’ll be easier for the client to swallow than removing E.T.L.D.!

Thanks, @texnixe – I’d love to solve this and come up with the ultimate multisite/one-panel recipe, but for now I may indeed go with two panels, with links in info sections to connect them. I think the Enhanced Toolbar Link Dialog is more of a neccessity for users.