NC12 theming: override $image-login-background


I’m developing a custom theme for my NC12. Using the getScssVariables() method, I want to set the login background image according to some dynamic conditions.

However, I’ve noticed that core/css/guest.css, where

body {

is defined, is the only stylesheet which is not using SASS (scss) format. Thus, although $image-login-background is defined at core/css/variables.scss, it has no effect since guest.css will not read it.

Is there a reason for that? May I propose a patch for it?


ps: a theming category for this forum would be useful…

1 Like

The reason there is a guest.css that does not use SCSS is, that in some cases the server is required to work with a minimal set of functions to avoid breaking stuff. The built in SCSS generator need access to the app data API and caching for example which is not available on installation and in maintenance mode.

So in a custom theme you would need an aditional guest.css in your theme folder to overwrite that styles as well.

Hi, Julius, thanks for your answer.

I was asking about the $image-login-background because I wanted to have it dynamically defined at defaults.php, according to the domain used.

But, if I understood you right, the $image-login-background variable cannot be used at all.

Actually, my current solution if to define the theme dynamically at the config.php, like this:

if (isset($_SERVER['SERVER_NAME'])) {
  switch ($_SERVER['SERVER_NAME']) {
       case 'bla.nextcloud12.localhost':
          $CONFIG['theme'] = 'bla-theme';
          $CONFIG['theme'] = 'default-theme';        
} else {
    $CONFIG['theme'] = 'default-theme';

This is working quite fine. The only drawback is that some infos as the favicon address are being cached on redis server. But this is not sooo bad.


Yes, that is not possible there at the moment.

Interesting solution. I would have expected to be some issues there with the SCSS caching as well, but if it works fine, that’s great. :thumbsup:

There has already been a fix merged for this: :wink:


After sometime using the solution above, I found another drawback, which this time is quite worse.

I’ve noticed that config.php is rewritten every time the configuration changes. Thus, the switch code gets erased.

Since this last discussion, was there some advance on the possibility of having different themes for groups/domains in NC?

Any news here?