Blank as initial app, and there call menu01 or menu02 according a condition

Hello friends.
I’m a newbie in Scriptcase.
I have this project whose initial app is a menu that has as default app a dashboard with several sections that show different things: news, photos, weather widgets, etc. It works as a news portal.
The problem is that accessing from a cell phone the portal does not look good at all.

I found that there is a library called Mobile_Detect that can help, but I never used an external library before. I have to see how to load and use it.
When I solve this matter, my idea is the following:
Use as initial app a blank app, that at the beginning of the load use this library to determine if it’s a PC or a mobile, and according to this show a menu01 with his default app dashboard designed for PC, or another menu02 with another default app dashboard designed for mobile.
Any ideas on how to implement all this?

I currently use SC 9.0.0.42

Thanks

Daniel

Hello Daniel,

I just checked into this and added the external library of Mobile Detect (http://mobiledetect.net/) into an external library.
Usually you would have to add something like to add the library:


   // Load Library
   require_once sc_url_library('sys', 'mobile_detect', '/Mobile-Detect-2.8.31/Mobile_Detect.php');

But it seems that Scriptcase already has included the library :confused:
Didn’t find any documentation about this at Scriptcase help …

Therefore you can build a new app of type blank and ad into onExecute Event:

 $detect = new Mobile_Detect;

if ( $detect->isMobile() )
  {
    echo "It's on mobile";
  }
else
  {
    echo "NO mobile";
  }

if( $detect->isAndroidOS() )
{
  echo "<br>... and it is ANDROID !<br>";
}

Executing the app will show you if your app is running on a mobile or desktop PC.

If you want to call your apps menu01 or menu02, you can use some code like:

 if ( $detect->isMobile() )
  {
    sc_redir(menu01);
  }
else
  {
    sc_redir(menu02);
  } 

I hope, this will answer your question.

Regards

1 Like

SOLVED !
Thank you very much Gunther, your example works perfectly for me, it’s exactly what I needed.
Daniel