{"id":414,"date":"2018-03-30T23:04:30","date_gmt":"2018-03-30T21:04:30","guid":{"rendered":"https:\/\/asdw.de\/?p=414"},"modified":"2018-03-30T23:04:30","modified_gmt":"2018-03-30T21:04:30","slug":"check-if-scriptcase-project-on-pc-or-mobile-device","status":"publish","type":"post","link":"https:\/\/asdw.de\/en\/check-if-scriptcase-project-on-pc-or-mobile-device\/","title":{"rendered":"Check if ScriptCase Project on PC or mobile device"},"content":{"rendered":"<h2>Is the Application running on a mobile device?<\/h2>\n<p>Download and use the class mobiledetect (<a href=\"http:\/\/mobiledetect.net\">http:\/\/mobiledetect.net<\/a>) as an external library in your Scriptcase Application.<\/p>\n<p>Usually you would have to add something like to add the library:<\/p>\n<pre class=\"lang:php decode:true \" title=\"Lade externe Bibliothek\">\/\/ Load Library\r\nrequire_once sc_url_library('sys', 'mobile_detect', '\/Mobile-Detect-2.8.31\/Mobile_Detect.php');<\/pre>\n<p>But it seems that Scriptcase already has included the library :\/<br \/>\nDidn&#8217;t find any documentation about this at Scriptcase help &#8230;<\/p>\n<p>Therefore you can build a new app of type blank and ad into onExecute Event:<\/p>\n<p>We&#8217;ll build an application to check if a mobile device is used and call <em>menu01<\/em> instead of <em>menu02<\/em> (for PC displays).<\/p>\n<p>To make it clear we&#8217;ll first use a code to show, which kind of device is used:<\/p>\n<pre class=\"lang:php decode:true  \" title=\"Anzeigen, auf welchem Ger\u00e4te-Typ gerade gearbeitet wird.\">$detect = new Mobile_Detect;\r\n\r\nif ( $detect-&gt;isMobile() )\r\n  {\r\n    echo \"It's on mobile\";\r\n  }\r\nelse\r\n  {\r\n    echo \"NO mobile\";\r\n  }\r\n\r\nif( $detect-&gt;isAndroidOS() )\r\n{\r\n  echo \"&lt;br&gt;... and it is ANDROID !&lt;br&gt;\";\r\n}<\/pre>\n<p>Executing the app will show you if your app is running on a mobile or desktop PC.<\/p>\n<p>If you want to call your apps menu01 or menu02, you can use some code like:<\/p>\n<pre class=\"lang:php decode:true  \" title=\"Verzweigen in Men\u00fcs je nach Ger\u00e4tetyp\">$detect = new Mobile_Detect;\r\n\r\nif ( $detect-&gt;isMobile() )\r\n  {\r\n    sc_redir(menu01);\r\n  }\r\nelse\r\n  {\r\n    sc_redir(menu02);\r\n  }<\/pre>\n<p>Using a mobile device will call <em>menu01<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is the Application running on a mobile device? Download and use the class mobiledetect (http:\/\/mobiledetect.net) as an external library in your Scriptcase Application. Usually you would have to add something like to add the library: \/\/ Load Library require_once sc_url_library(&#8216;sys&#8217;,<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/asdw.de\/en\/check-if-scriptcase-project-on-pc-or-mobile-device\/\">Read more &#8250;<\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[128,129,50],"_links":{"self":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/414"}],"collection":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/comments?post=414"}],"version-history":[{"count":2,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/414\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/media?parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/categories?post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/tags?post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}