Q : Why use this template syntax instead of CSS media query ?
A : That is personal preference. But personally i think hiding content with CSS is not "100% proper", because the browser still loads the HTML code. And it depends on your case too.
Q : Why mobile detection result is wrong ? (for example mobile phone is not detected as mobile)
A : Try live demo of the library that i use here :
http://demo.mobiledetect.net/
If the result there is wrong, then their user agent database is incorrect / outdated.
Q : I still want to use this add on with guest page caching enabled, and i only use cutemb_is_mobile() and i don't use other functions such as cutemb_is_chrome().
A : The answer is quite long :
- You create a PHP file, named
guest_page_caching_mobile_detect.php
in your /src/
- Open this https://raw.githubusercontent.com/serbanghita/Mobile-Detect/master/Mobile_Detect.php
Copy and paste the content into your guest_page_caching_mobile_detect.php
- Find Line #25
Change into
PHP:
class Guest_Page_Caching_Mobile_Detect
- Backup your
config.php
to your local computer.
- Open your
config.php
file and add these lines (line position doesn't matter)
PHP:
require_once('guest_page_caching_mobile_detect.php');
$_detect = new Guest_Page_Caching_Mobile_Detect();
define('MY_IS_MOBILE', intval($_detect->isMobile()));
- Open
/xrc/XF/PageCache.php
, backup a copy to your local computer.
- Find this line (#261) :
PHP:
return 'page_' . sha1($uri) . '_' . strlen($uri) . "_s{$styleId}_l{$languageId}_v" . self::CACHE_VERSION;
- Change into :
PHP:
return 'page_' . sha1($uri) . '_' . strlen($uri) . "_s{$styleId}_l{$languageId}_v" . self::CACHE_VERSION.'_m'.constant('MY_IS_MOBILE');
- Save.
- Now guest page caching should work in both mobile & non-mobile.