Hi everyone, I am wondering if there is a way to create 2 views in the Perspective, and make it so View 1 launches when the user logs in with a mobile device, and View 2 launches when the user logs in with a laptop.
I'm not sure if I could create a size requirement, like launch view 1 if the device is less that 800x800 pixels, else open view 2 or something like that.
Does the Perspective know the size screen of the device logged into it?
Thanks!
If you haven't already, then I recommend Inductive University Course List - Learn Ignition Free.
In the documentation:
Have a look at the Breakpoint Container before you go your proposed route. One of Perspective's big selling points is the flexible layout and mobile responsiveness. Perspective - Breakpoint Container | Ignition User Manual
There's also the Column Container but many of us have gone mad trying to modify the layout in these. Moving a component tends to many of the others. Perspective - Column Container | Ignition User Manual
Then there's the Flex Container which can accommodate wrapping when things get too narrow. Perspective - Flex Container | Ignition User Manual
All of the container types are listed on Perspective - Container Palette | Ignition User Manual.
1 Like
I don't think they're looking to open a different View based on viewport size - it sounds like they're trying to open a different View based on machine or location.
There's no good way to manage this in Perspective. You can use the Page Startup Event to make a check against the device in use, but this is performed for every tab the user may open during the life of their session. You could use the Session Startup Event... that might work.
if session.props.host = "X.X.X.X":
# navigate
1 Like
If you just want to show different view because of the screen size, then as Transistor mentioned, a breakpoint or column container will do what you need.
If you actually need to know if the user is on a mobile device, you can search the session.props.device.useragent string to see if it contains "mobile"
You could in fact bind a custom session property to the device useragent and have an is_mobile custom session property.