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

Different themes for subsites #126

Open
Zerogiven opened this issue Nov 21, 2022 · 0 comments
Open

Different themes for subsites #126

Zerogiven opened this issue Nov 21, 2022 · 0 comments
Labels

Comments

@Zerogiven
Copy link

Zerogiven commented Nov 21, 2022

Hi,

I have the problem that i must have different login styles for different subsites. So i can set the config globally with "login_themes" but i can't set a theme by default and a login theme for a subsite.

As possible workaround i've added some lines of code to add the subsite theme priority.

I'm not sure if there would be a better workaround to get this problem done.

Take a look at the line beginning with "if (class_exists(Subsite::class) === true) {", there are the lines which i would change/add:

    public function beforeCallActionHandler()
    {
        $config = Config::inst();
        /** @var Security $owner */
        $owner = $this->getOwner();
        $action = $owner->getAction();
        $allowedActions = $config->get(Security::class, 'allowed_actions');
        $excludedActions = $config->get(self::class, 'excluded_actions');
        $themeActions = array_diff($allowedActions ?? [], $excludedActions);
        if (in_array($action, $themeActions ?? [])) {
            if (class_exists(Subsite::class) === true) {
                $themes = $config->get(self::class, 'login_themes');

                array_unshift($themes, Subsite::currentSubsite()->Theme);

                SSViewer::set_themes($themes);
            } else {
                SSViewer::set_themes($config->get(self::class, 'login_themes'));
            }
        }
        $this->defaultPageClass = $config->get(Security::class, 'page_class');
        Config::modify()->remove(Security::class, 'page_class');
    }

If this workaround will be approved by you i also can make a pull request :)

Better ideas are welcome :) :)

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

No branches or pull requests

2 participants