Help with modifying mobile_detect.php to exclude tablets.

Permalink 1 user found helpful
Hi All,

My php ain't so hot - does anyone know how to exclude tablets in mobile_detect.php? I'm building with 5.6.1.

Cheers,
Judd

juddc
View Replies:
webtodesigns replied on at Permalink Reply
webtodesigns
Has anyone found a solution for this?

There should be an option in the next conc5 update that allows you to select weather or not you want the mobile theme to include tablets or not. Even better would be great if you have three options as themes.

-Garen
juddc replied on at Permalink Reply
juddc
I haven't had to with the newer mobile_detect.php. I agree - tablets shouldn't be treated as mobile by default.
enlil replied on at Permalink Reply
enlil
if( $detect->isMobile() && !$detect->isTablet() ){
 // is mobile but not tablet, do stuff here
}


the mobile_detect library appears to be from http://www.mobiledetect.net although the version included in 5.6.1.2 is quite different from the latest release available.
webtodesigns replied on at Permalink Reply
webtodesigns
Hey enlil,

That looks just about right.
But the the problem I was referring to is when you create a new template and apply it as mobile theme.

I believe tbe way you are suggesting applies if you use one theme for mobile/tablet/desktop.

Correct me if I am wrong though.

-Garen
enlil replied on at Permalink Reply
enlil
Here is an example of code i just tested to either force a different theme if mobile or display a global area as usual for tablet/normal browser. Short of having a tablet at my dispense to test that end of it, everything appears to be working correctly! If this be the case you should be able to adapt this to accomplish what you are looking for!

<?php Loader::library('3rdparty/mobile_detect');
$detect = new mobile_detect();
if($detect->isMobile() && !$detect->isTablet()) {
echo t('Mobile!!!!!!!!!!!!!');
$view->setTheme(PageTheme::getByHandle('enlil_transparency'));
} else { ?>
   <div class="content">
   <?php   $a = new MagicGlobalArea('Sidebar Header');
      $a->display(); ?>
   </div>
<?php } ?>
webtodesigns replied on at Permalink Reply
webtodesigns
Hi enlil,

That still means you need to include it in the header file of of your main template.

Valid, and should work.

but it gives me an idea, shouldn't we be able to adjust one of the core files in concrete5 that determines which theme to show weather if it is a mobile, tablet, or desktop?

Been looking for it since the morning, can't seem to find it :/

-Garen

*Edited:
That said, should be able to make an addon that will allow you to select three theme, mobile, tablet and desktop.
guyDesign replied on at Permalink Reply
In concrete/core/libraries/view.php
line 574 (in checkMobileView function )

change: if ($md->isMobile())
to: if ($md->isMobile() && !$md->isTablet())