Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/view.php
Last active Aug 29, 2015

Embed
What would you like to do?
#concrete5 Override View to exclude tablet devices from checkMobileView
<?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
You can’t perform that action at this time.