NetTalk Central

Author Topic: How to change theme in code?  (Read 4464 times)

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
How to change theme in code?
« on: January 12, 2012, 04:16:03 PM »
In ther properties of the NetTalk extension on the Web Server I have set the Theme to be GLO:Theme

I am setting GLO:Theme in the Process Link embed of the Web Handler (before Parent Call). However when I start the application no theme is selected.

Where and how is the best way to allow my users to change a preference and apply a different theme?

John

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: How to change theme in code?
« Reply #1 on: January 13, 2012, 12:59:59 AM »
Just a bit more on this one. I found an embed point in the Web Server "Override Server Settings" and used s_web._SitesQueue.Defaults.DefaultTheme. It did not work but there is an added complication I came across.

I am using multi user login and so the data path of the users preference file is not set until Login and this code needs to be actioned prior to the login screen.

So I guess what I am trying to do is to set s_web._SitesQueue.Defaults.DefaultTheme and somehow REFRESH at that point to pick up the new settings. How would I do that?

Also it seems like I am always going to have this problem unless I have some master file sitting at root level say which holds each users preferences. Doing that at least guarantees I know the path name before Login.

John

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to change theme in code?
« Reply #2 on: January 13, 2012, 02:43:48 AM »
Maybe you should look at storing the Theme Name in a cookie instead as you will never know what theme to apply until after the user logs in.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11260
    • View Profile
Re: How to change theme in code?
« Reply #3 on: January 13, 2012, 04:20:29 AM »
The theme is set via the use of a Value called _theme_.

If you had a form, and on that form was a field called _theme_ then when that form is completed the _theme_ is automatically updated. Thus the easiest way to let the user select the theme is to
a) make a form, with a drop-down, that you populate with all the valid theme names.
b) the name of the drop down dield should be set to _theme_
c) when the user clicks on the "save" button on the form, the theme will change (that'll only be visible though on the next page refresh.)

In code you can change the theme as well, by setting a value and calling SetTheme.

p_web.SetValue('_theme_',whatever)
p_web.SetTheme()

So, for example, an ideal place to do this is when the user logs in, as part of the login validation process.

Of course the theme is bound to the _session_ so multiple users can access the site, using different themes at the same time.

there are a couple ways you could differentiate your _login_ screen so that a different theme is show _before_ we even know who the user is. The one way is to set a cookie, called _theme_, that contains the theme name. (See docs on cookies.)

Another option (although more complex to set up) would be to base it on the URL used. for example john.capesoft.com might get a different theme to bruce.capesoft.com. But this approach is based on the whole idea of putting different customers on different URL's - which is a fair bit more management on your side for each new customer. (but has the potential to scale more easily as well.)

cheers
Bruce


John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: How to change theme in code?
« Reply #4 on: January 13, 2012, 06:27:36 AM »
Sorry Bruce. My code is:

p_web.SetValue('_theme_',LOC:Theme)
p_web.SetTheme()

But it does not like SetTheme() - error is FiledNotFound:SetTheme and Unknown Procedure label on Line 2

I must be missing something.

John

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: How to change theme in code?
« Reply #5 on: January 14, 2012, 12:54:52 AM »
Bruce hunted all the docs and source code but p_web.SetTheme() does not appear to exist. Cannot compile.

Is there an example with this working?

Thanks

John

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: How to change theme in code?
« Reply #6 on: January 15, 2012, 06:03:53 PM »
Try p_web.ChangeTheme()