Last active
August 29, 2015 14:04
-
-
Save hissy/061bca97a918e20cda4c to your computer and use it in GitHub Desktop.
#concrete5 Override View to exclude tablet devices from checkMobileView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// For concrete5 ~5.6.x | |
// libraries/view.php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
class View extends Concrete5_Library_View { | |
public function checkMobileView() { | |
if(isset($_COOKIE['ccmDisableMobileView']) && $_COOKIE['ccmDisableMobileView'] == true) { | |
define('MOBILE_THEME_IS_ACTIVE', false); | |
return false; // break out if we've said we don't want the mobile theme | |
} | |
$page = Page::getCurrentPage(); | |
if($page instanceof Page && $page->isAdminArea()) { | |
define('MOBILE_THEME_IS_ACTIVE', false); | |
return false; // no mobile theme for the dashboard | |
} | |
Loader::library('3rdparty/mobile_detect'); | |
$md = new Mobile_Detect(); | |
if ($md->isMobile() && !$md->isTablet()) { | |
$themeId = Config::get('MOBILE_THEME_ID'); | |
if ($themeId > 0) { | |
$mobileTheme = PageTheme::getByID($themeId); | |
if($mobileTheme instanceof PageTheme) { | |
define('MOBILE_THEME_IS_ACTIVE',true); | |
// we have to grab the instance of the view | |
// since on_page_view doesn't give it to us | |
$this->setTheme($mobileTheme); | |
} | |
} | |
} | |
if (!defined('MOBILE_THEME_IS_ACTIVE')) { | |
define('MOBILE_THEME_IS_ACTIVE', false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment