Kirby multiple websites questions

Hey…
today i just purchased a second license for another website… since both websites will only differ in domain-name and content-folder, my idea was to have same site folder.
Is it possible to have two licenses in the same folder? i tried to register one after each other. but the .license file was overwritten each time.

thx

those three links did not help for the license-file question:

The license is written into the config folder, therefore I guess you need a different config folder for each site (put that folder together with the content folder).

(new Kirby([
   //...
   'roots' => [
     //...
     'config' => "$websiteRoot/config"
   ]
])->render();

Of course that folder then needs to also contain your config file (if you have one), and if you want to keep that “DRY”, you could always copy a config file that just returns the values of a global one:

<?php

return include '/my/global/config.php';

well… there is a possibility for multisite configs in the same configfolder… that makes only sense if the same goes with licenses… or did i oversee something? =)

You mean this https://getkirby.com/docs/guide/configuration#multi-environment-setup ?

I think that feature is intended to support “the same site in different environments”, like: a config file for testing, one for staging, one for production.
Not so much for “different sites in the same environment”.

Multiple Licenses in one file or multiple licensefiles in one folder would open such environment =)

@rasteiner thx a lot… it seems to work with your solution on config folder…

now, since i managed the license-question, i got new questions…

is it possible to rewrite base for multiple sites? reason: every site has now urls like domain.tld/subfolder/... for everything except pages… so for the the media and assets.

that makes it difficult for some urls pointing to "/assets/..." maybe this is bad coding behaviour… but there are plugins that use root folder as base… in my case “lessphp” of thezero theme throws: File /var/www/html/assets/app/custom/app.less not found.#

in Line 2793 /var/www/html/site/plugins/lessphp/lib/Less/Parser.php
whenn enabling style compiler. and also assets are not found, because url generating of css, js etc. is now broken… @mrfreedom any idea on this?

Hi, @demlak.

Yes, site/theme/snippets/less.php is using realpath linking. Some people suggested it, because of issues in some environments, so I whent along. Just change it.

Open that file and at the top you will see

// Using 'realpath' seems to work best in different situations.
$root = realpath(__DIR__ . "/../../..");

Just change the code before Less library activation.

1 Like

thx a lot…

i was able to manage the style compiling by setting correct paths in the snippet…

// Main Less file.
$sourceFile = $kirby->root('assets') . "/app/custom/app.less";
// Final CSS file.
$compiledFile = $kirby->root('assets') . "/app/dist/css/uikit.app.min.css";

// Options
$options = array(
    'compress'=>true,
    'cache_dir' => $kirby->root('site') . '/cache/less'
);

but the generated output still produces wrong urls to assets…
for example (as you can see: no numbers before file extensions):

    <link href="https://www.ecovillage-hannover.de/assets/app/dist/css/uikit.app.min..css" rel="stylesheet">  
  <script src="https://www.ecovillage-hannover.de/assets/app/dist/js/uikit.min..js"></script>
  <script defer src="https://www.ecovillage-hannover.de/assets/app/dist/js/uikit-icons.min..js"></script>  
1 Like

Than that’s the issue with Kirby 3 Cachebuster plugin.
Make sure you added Cachebuster htaccess code for that other website.

thx a lot…
i disabled the plugin to test… (tried also with or without the coresponding part in the .htaccess file)

still there were hardcoded folders in snippet header.php

i changed them:

  <?= css([$kirby->url('assets') . '/app/dist/css/uikit.app.min.css']) ?>
  <?= css('@auto') ?>

  <?= js($kirby->url('assets') . '/app/dist/js/uikit.min.js') ?>

  <?= js($kirby->url('assets') . '/app/dist/js/uikit-icons.min.js', ['defer' => true]) ?>
  <?= js('@auto') ?>

now it works without cachebuster plugin… i’ll try to contact @schnti via github issue… we’ll see…

i fixed it: https://github.com/schnti/kirby3-cachebuster/issues/7#issuecomment-723351017
(Edit: narf… now i see, there is already a pull request from may 2019, which also reflects this… this plugin seems to be orphaned)

now… everything in multi-url setup works…
but i still would prefer to hide subfolder of each domain…

is it possible to rewrite base for multiple sites? reason: every site has now urls like domain.tld/subfolder/… for everything except pages… so for the the media and assets.

Because i choose a very generic title for this thread… i push my own thread with another question =)

In this multisite Setup i try to add a new editor-profile for example site/theme/blueprints/users/editor-dl.yml

how to restrict those user roles to a panel of a specific domain/site? if i enable this role… it is enabled for all sites… and those users are able to log into every site and have same userrights on all sites… thats not wanted.

any idea on that?

I’d register those user blueprints conditionally in a plugin based on domain

hmm… interesting idea…

like "if domain = x → this blueprint-file… " “else → that blueprint-file”?

this seems promising Programmable blueprints | Kirby CMS

Yep

my idea was about this…

<?php

use Kirby\Cms\App as Kirby;

Kirby::plugin('dmlk/programmable-blueprints', [
    'blueprints' => [
        'users' => [
            'editor-dl' => function () {
                $gethost = Url::host();
                if (($user = kirby()->user()) && ($gethost = 'www.example.de')) {
                    return Data::read(__DIR__ . '/blueprints/users/editor-dl.yml');
                } else {
                    return Data::read(__DIR__ . '/blueprints/users/editor-none.yml');
                }
            },
        ]
    ]
]);

this seems to be a conceptional failure… because i can’t find any additional roles in Role-Management/Setting of user.

Your syntax is not correct, you don’t register blueprints with keys per type, so it would have to be:

 'blueprints' => [
            'users/editor-dl' => function () {
                if (Url::host() = 'www.example.de') {
                    return Data::read(__DIR__ . '/blueprints/users/editor-dl.yml');
                } else {
                    return Data::read(__DIR__ . '/blueprints/users/editor-none.yml');
                }
            },
    ]

Also, it doesn’t make sense to check for the Kirby user.

Also, this still registers an editor-dl user. So I’d say the if statement should be outside of the blueprint registration

hmmmm…

Fatal error: Can't use method return value in write context in /var/www/html/site/plugins/dmlk.programmable-blueprints/index.php on line 8

and also unexpected error when i declare it like this:

<?php

use Kirby\Cms\App as Kirby;

Kirby::plugin('dmlk/programmable-blueprints', [
 'blueprints' => [
            'users/editor-dl' => function () {
                $gethost = Url::host();
                if ($gethost = 'www.example.de') {
                    return Data::read(__DIR__ . '/blueprints/users/editor-dl.yml');
                } else {
                    return Data::read(__DIR__ . '/blueprints/users/editor-none.yml');
                }
            },
    ]
]);