Skip to content

Different themes for subsites #126

Open
@Zerogiven

Description

@Zerogiven

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 :) :)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions