Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Different theme for login screen?


Go to End


6 Posts   979 Views

Avatar
Peavers

Community Member, 20 Posts

8 June 2015 at 5:16pm

Edited: 08/06/2015 5:16pm

Hello,

I'm attempting to switch out the current theme with a completely different one whenever at the login screen. However testing the concept of switching themes on the fly doesn't seem to be working...

class PageExtension extends Extension
{
    public function onBeforeInit()
    {
        Debug::message(SSViewer::get_theme_folder());

        SSViewer::set_theme('login-theme');

        Debug::message(SSViewer::get_theme_folder());

        parent::init();
    }
}

---
Name: custom-login
After:
  - 'framework/*'
  - 'cms/*'
---
Page_Controller:
  extensions:
    - PageExtension

Shows the theme folder is switching, but the default theme is still being loaded. Do I need to call re-render or something similar?

Any ideas on how to go about this?

Avatar
Pyromanik

Community Member, 419 Posts

9 June 2015 at 9:15am

Yeah, that's not particularly a good idea.

Just make a template Security.ss
and/or Security_login.ss

Place it in the 'main' templates folder (ie, not Layout).

?flush

Avatar
Peavers

Community Member, 20 Posts

9 June 2015 at 9:29am

That isn't what I'm trying to achieve so isn't really of much help.

We run about 15 different sites on the same instance, each with their own theme and own 'core'. The goal here is to create a unified login screen as a module. So I want to override every other Security_login.ss, hence the extension.

The reasons aside, should the code above not be working correctly?

Avatar
Pyromanik

Community Member, 419 Posts

9 June 2015 at 9:50am

Edited: 09/06/2015 10:00am

Avatar
Peavers

Community Member, 20 Posts

9 June 2015 at 10:34am

Worked perfectly, thanks for the answer.

Avatar
Pyromanik

Community Member, 419 Posts

9 June 2015 at 10:39am

You're welcome :)