Branding for sub-domains

Hi,

I was wondering if anyone can tell me it it is possible to have the branding items you see in the Project Properties in Studio change depending on the subdomain. I’m hoping there is some early way in to CUBA to change these.

For example.

client1.mycompany.com/app
Shows Client1’s Branding

client2.mycompany.com/app
ShowsClient2’s branding

Thanks for any help.

Hi,

You can get current URL address from web browser and assign top-level CSS class for the entire web page something like (Create extended main window using CUBA Studio screen template):

public class ExtAppMainWindow extends AppMainWindow {
    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        URI location = Page.getCurrent().getLocation();
        if (location.getHost().contains("host")) {
            // add styles to the web page root
            AppUI.getCurrent().addStyleName("customer-branding-host");
        }
    }
}

Then add your CSS customization to the extended theme:

  .customer-branding-host .c-inverse-header.c-app-menubar {
    background: red;
  }
1 Like

Hi @artamonov

Thanks for that information. I got what i needed working from that.