Theme based on url/server

260 views
Skip to first unread message

Nicolas Micoud

unread,
Jun 16, 2022, 11:24:51 AM6/16/22
to iDempiere
Hi,

Our SaaS solution is reachable via several urls, according to timezones : americas / emea and we recently added a server for a customer which has lots of users.
Now we would like to change the logo from the login page (and maybe the theme with difference icons) when this dedicated server is used.

In other words, ATM the theme is set at DB level, we would like to be able to set it at server level (tenant level is not enough as the login page doesn't which tenant(s) can be used there).

I haven't tested, but I think changes would be required in ThemeManager.getTheme, with something like:

String theme = System.getProperty(MSysConfig.ZK_THEME + WebUtil.getServerName());
       
if (Util.isEmpty(theme))
    theme = System.getProperty(MSysConfig.ZK_THEME + WebUtil.getHostIP());    

if (Util.isEmpty(theme)) // fallback to the default
    theme = System.getProperty(MSysConfig.ZK_THEME);

In the plugin that will contains themes, we can have :

web\theme\themeTenant1
web\theme\themeTenant2
web\theme\theme192.168.1.10

wdyt?

Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Jun 16, 2022, 1:25:12 PM6/16/22
to idem...@googlegroups.com
As you say it's a dedicated server for a specific customer, you can do
it at this moment simply setting the variable ZK_THEME in that server
different than the other servers.

I think you can do that setting a global a context variable, something like:
export ZK_THEME=themeDedicatedTenant1



El 16/6/22 a las 17:24, Nicolas Micoud escribió:
> Nicolas --

Nicolas Micoud

unread,
Jun 17, 2022, 3:08:44 AM6/17/22
to iDempiere
Hi Carlos,

Indeed, I didn't notice the first retrieval was done using a System.getProperty (I thought it was a MSysConfig.getValue).

So, I try to add export ZK_THEME=default in idempiere service but it was not working.

The only way to make it work was to add it in idempiereInit.properties file.

Do you think is ok this way?

Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Jun 20, 2022, 10:06:37 AM6/20/22
to idem...@googlegroups.com
xref


El 17/6/22 a las 9:08, Nicolas Micoud escribió:

Nicolas Micoud

unread,
Jun 24, 2022, 10:21:37 AM6/24/22
to iDempiere
Hi,

Ability to define the theme on the server is working well, but there are some missing pieces.
ATM, logos and browser icon/title are still read from DB and cannot be set at server level.

Is it ok if I update the related methods and first try to get the value from system properties and if not found, take from DB :

For instance, ThemeManager.getLargeLogo() will be something like:

public static String getLargeLogo() {
    String logo = System.getProperty(ITheme.LOGIN_LOGO_IMAGE);
    if (!Util.isEmpty(logo))
        return logo;

    String theme = getTheme();
    String def = THEME_PATH_PREFIX+theme+ITheme.LOGIN_LOGO_IMAGE;
    return MSysConfig.getValue(MSysConfig.ZK_LOGO_LARGE, def);
}


wdyt?

Thanks

Nicolas

Heng Sin Low

unread,
Jun 24, 2022, 10:38:23 AM6/24/22
to idem...@googlegroups.com
getLargeLogo() get from theme and your theme is per server ...

Perhaps you have just picked a bad example to illustrate your need ?

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/57e1eff9-c9bd-45c9-9fd2-d1ab2818d02bn%40googlegroups.com.

Heng Sin Low

unread,
Jun 24, 2022, 10:41:26 AM6/24/22
to idem...@googlegroups.com
hmm .. looks like I have misread it, msysconfig value takes priority over the theme path, looks like you need it the other way round here.
 
would deactivate the msysconfig record works for you here ?

Nicolas Micoud

unread,
Jun 24, 2022, 10:58:03 AM6/24/22
to iDempiere
Correct!

I didn't realize the name were different on the 2 themes I used for my tests.
If they have the same name, logo and browser icon are ok.
I also had to deactivate the related records from AD_SysConfig.

So I think the only thing that cannot be set at server level is the browser title which is read from SysConfig (or from zk.xml).
So, change should be done in DefaultWebAppInit.init(WebApp) ?

Heng Sin Low

unread,
Jun 24, 2022, 11:07:51 AM6/24/22
to idem...@googlegroups.com
preference.zul inside theme might works for that, try it out.

Nicolas Micoud

unread,
Jun 24, 2022, 11:24:55 AM6/24/22
to iDempiere
I've made the following change in preference.zul :

Original version (line is commented) :
2022-06-24 17_20_06-orig.png


Updated version :

2022-06-24 17_20_55-after.png

Refresh (Eclipse + browser + Incognito mode) ; iDempiere is still displaying as tab browser.
Did I miss something?

Heng Sin Low

unread,
Jun 25, 2022, 7:32:55 AM6/25/22
to idem...@googlegroups.com
Don't remember now the history behind this but it seems this is not implemented in current code.

You can try call AEnv.getDesktop().getWebApp().setAppName("app name") ; in preference.zul (need to add import org.adempiere.webui.apps if it is not in there yet).

Nicolas Micoud

unread,
Jun 27, 2022, 2:33:38 AM6/27/22
to iDempiere
Hi,

Is working, thanks

Do you think is worthy to add this in trunk as a comment (same as #ZK_BROWSER_TITLE)?

Heng Sin Low

unread,
Jun 27, 2022, 3:42:43 AM6/27/22
to idem...@googlegroups.com
yes, that should replace the not working #ZK_BROWSER_TITLE comment.

Nicolas Micoud

unread,
Jun 27, 2022, 9:08:10 AM6/27/22
to iDempiere
Reply all
Reply to author
Forward
0 new messages