NetTalk Central

Author Topic: Different themes for sessions  (Read 4662 times)

hkalmbach

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
    • Email
Different themes for sessions
« on: December 20, 2016, 03:21:40 AM »
Hi together,

is it possible to use different themes in one WebServer depending on the sessions?
That means use one theme for desktop clients (p_web.IsMobile=false) and another theme for mobile clients (p_web.IsMobile=true)

I found a chapter in the NetTalk book where I can change the theme by p_web.ChangeTheme('ThemeName'). This works if you don't use the 'detect' setting in the web handler and it works for desktop always. But what I would like to do is to have the WebHandler in detect mode to see if the client is a mobile device or not and then change the theme to a non-mobile theme.

Is it possible to deactivate the detect mode for a session after one knows that the client is mobile or desktop?
Or can I change also the mobile theme it detection is active?

Thanks for help.

Cheers
Heinz
« Last Edit: December 20, 2016, 05:18:02 AM by hkalmbach »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Different themes for sessions
« Reply #1 on: December 22, 2016, 01:38:06 AM »
Hi Heinz,

>> Is it possible to use different themes in one WebServer depending on the sessions?

yes, and as you pointed out, for Desktop it works well.
For Mobile it's going to work less well, because the mobile app doesn't refresh the pages in the same way.
I would say, for mobile users, it's going to get tricky.

As a side note, the concept of using a different framework for small devices (ie switching to jQuery Mobile), is probably on the wane. The last while I've been advocating rather using the Desktop framework in all cases, and then using an appropriate style for the size of the screen.

I've discussed this a couple times in the last 6 months on the user group webinars, and it seems to be working well that way. I can forsee a time when the jQuery Mobile support is deprecated in favor of a more inclusive desktop framework.

cheers
Bruce

hkalmbach

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
    • Email
Re: Different themes for sessions
« Reply #2 on: December 22, 2016, 02:58:00 AM »
Hi Bruce,

this I understood. I don't any longer want to use the mobile framework. I made some forms (smaller, less fields) for mobile devices in desktop mode and it works very well and with the theme 'seven' looks pretty good.

My question is, even if I want to use the desktop framework for all clients, I want to know if a client is mobile or desktop. This I want to know because I want to use different forms for desktop and mobile.

If I set the webhandler to desktop mode, the function p_web.IsMobile does not return 1 for mobile devices.
If I set the webhandler to detect mode, the function p_web.IsMobile does return the correct value but for mobile devices automatically the mobile framework and mobile theme is used.

Is it possible to detect if a client is mobile but always use the desktop framework?

Thanks a lot

Cheers
Heinz



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Different themes for sessions
« Reply #3 on: December 22, 2016, 05:38:18 AM »
Hi Heinz,

I see where you are going with this - yes, it makes sense.
But rather than describe the device as "mobile" (because that's hard to define) perhaps it would be better to have some way of detecting if the device is
a) on a small screen and/or
b) uses touch input.

Those are probably the two criteria that would have the biggest impact.
The small screen speaks to your layout, and what you have on the browse/form and the touch input means you need to make buttons a bit bigger.

Unfortunately these things can be hard to automatically "detect". Screen resolutions can be very high, even on devices with small screens.

It's definitely an area I can work on though so that we get some freedom in that area.

Cheers
Bruce

hkalmbach

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
    • Email
Re: Different themes for sessions
« Reply #4 on: December 22, 2016, 07:30:50 AM »
Hi Bruce,

sounds good.

As a fast solution, is it possible to get the available screen width and height perhaps in the IndexPage of the WebServer assign it to a session variable and afterwards with this variables select the visible buttons the user can press? How?

Thanks.

Cheers
Heinz

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Different themes for sessions
« Reply #5 on: December 22, 2016, 11:08:29 PM »
It already sends you session variables your app can use. (Assuming you've not disabled this, on the WebServer / Performance tab).
session values are
_screenwidth_ and
_screenheight_

Cheers
Bruce