Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multisite custom config keys #602

Closed
RafaelKr opened this issue Jul 14, 2021 · 1 comment · Fixed by statamic/cms#3996
Closed

Multisite custom config keys #602

RafaelKr opened this issue Jul 14, 2021 · 1 comment · Fixed by statamic/cms#3996

Comments

@RafaelKr
Copy link

I would like to have the following multisite config:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Sites
    |--------------------------------------------------------------------------
    |
    | Each site should have root URL that is either relative or absolute. Sites
    | are typically used for localization (eg. English/French) but may also
    | be used for related content (eg. different franchise locations).
    |
    */

    'sites' => [

        'subsidiary-1-de' => [
            'name' => '[DE] ' . env('SUB1_APP_NAME'),
            'locale' => 'de_DE',
            'url' => env('SUB1_APP_URL'),

            'theme' => 'subsidiary-1',
        ],

        'subsidiary-1-en' => [
            'name' => '[EN] ' . env('SUB1_APP_NAME'),
            'locale' => 'en_US',
            'url' => env('SUB1_APP_URL') . '/en',

            'theme' => 'subsidiary-1',
        ],

        'subsidiary-2-de' => [
            'name' => '[DE] ' . env('SUB2_APP_NAME'),
            'locale' => 'de_DE',
            'url' => env('SUB2_APP_URL'),

            'theme' => 'subsidiary-2',
        ],

        'subsidiary-2-en' => [
            'name' => '[EN] ' . env('SUB2_APP_NAME'),
            'locale' => 'en_US',
            'url' => env('SUB2_APP_URL') . '/en',

            'theme' => 'subsidiary-2',
        ],

        'subsidiary-3-de' => [
            'name' => '[DE] ' . env('SUB3_APP_NAME'),
            'locale' => 'de_DE',
            'url' => env('SUB3_APP_URL'),

            'theme' => 'subsidiary-2',
        ],

        'subsidiary-3-en' => [
            'name' => '[EN] ' . env('SUB3_APP_NAME'),
            'locale' => 'en_US',
            'url' => env('SUB3_APP_URL') . '/en',

            'theme' => 'subsidiary-2',
        ],

    ],
];

So that I can use {{ site:theme }} in my antlers to set a class on the body tag.

Maybe it could also look like this:

<?php

return [

    // [...]

    'sites' => [

        'subsidiary-1-de' => [
            'name' => '[DE] ' . env('SUB1_APP_NAME'),
            'locale' => 'de_DE',
            'url' => env('SUB1_APP_URL'),

            'config' => [
                'theme' => 'subsidiary-1',
            ],
        ],

        // [...]

    ],
];

and then it could be used with {{ site:config:theme }}.

My workaround for now would be to write a little Tag-Addon which would return the config based on the current site-handle.

@RafaelKr
Copy link
Author

RafaelKr commented Jul 14, 2021

BTW I'm happy to create a PR for this, if you decide what's the best way to implement it.

I like my second approach with the sub-array. But at second thought we shouldn't name it config because the code already calls the whole site configuration $config internally. Maybe we could call it attributes, properties, traits, etc. And then use the singular in the site-Tag (e.g. {{ site:attribute:theme }}). What do you think?

Edit: Probably it should also be plural in the site-Tag, feels more natural to me. {{ site:attributes:theme }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant