Hi,
Is it possible to force a form application in web version instead of mobile version ?
Thanks
Guy
v9.6.011
Hello,
Try it in the onScriptInit event:
$_SESSION[‘scriptcase’][‘device_mobile’] = false;
$_SESSION[‘scriptcase’][‘display_mobile’] = false;
Hi,
No change. doesn’t work
Guy
Hi,
I ended up falling down this rabbit hole due to a need to control the version presented to the user due to a bug with uploading and downloading files with paths that include variables in the mobile version. (e.g. /file/[user_id]/)
A couple of things. The quotes got messed up in the code above - it should be:
$_SESSION['scriptcase']['device_mobile'] = false;
$_SESSION['scriptcase']['display_mobile'] = false;
and it should be in AppInit (not ScriptInit)
These variables are from at least as old as SC 8. Based on quite a lot of trial and error:
$_SESSION['scriptcase']['device_mobile']
determines whether the ‘Display Web Version’ / ‘Display Mobile Version’ link is shown (true) or not (false).
$_SESSION['scriptcase']['display_mobile']
determines whether the version of the page displayed is the web version or the mobile version - something most obviously seen in the toolbar version shown. (but see below!)
It can be used with the function:
$detect = new Mobile_Detect;
if ($detect->isMobile())
{
//do something
}
to sense what is being used to view the page - although all of this is normally done automatically.
Second, there is an additional variable, which I think was introduced when the new mobile optimisation was added in V9.
This variable is $_SESSION['scriptcase']['proc_mobile']
This is only evaluated when enable mobile optimisation is on - otherwise it has no effect.
When this is set to true it forces the browser to use the mobile optimised format. When set to false it forces it to ignore this and use the main version. This is more obvious in grids with narrower columns and wrapping and the ‘bouncy arrow’ toolbar. In forms it was less clear.
This ends up as a complicated combination which I ended up writing as a table. It has taken so long to work though this, I thought important to share!
Also, when testing not only do you often need to clear the cache/hard reload but it is also necessary to leave the app (e.g. go back to the grid) and go back in again.
And one other bit… The session values don’t always seem to load first time (on forms at anyrate) so I also had to add a forced refresh in ScriptInit:
$detect = new Mobile_Detect;
if ($detect->isMobile())
{
if ($_SESSION['scriptcase']['display_mobile'] == 1 || $_SESSION['scriptcase']['display_mobile'] == true)
{
$_SESSION['scriptcase']['display_mobile'] = false;
sc_exit(sel);
}
}