Mobile detect

Permalink 1 user found helpful
Hi.
I'm trying to get mobile detect to work with c5
In my HTML / CSS template I have this php string

require_once 'mobile_detect.php';
$detect = new Mobile_Detect();
if( $detect->isMobile() && !$detect->isTablet() ) {$mobile = '1';}
if ($mobile == 1) {
    echo '<link href="css/mobile.css" rel="stylesheet">';
}else {
    echo '<link href="css/custom.css" rel="stylesheet">';
    }
?>

This code I put into my header.php
If I look at my source code, I can see that it makes this path
<link href="css/custom.css" rel="stylesheet">


But it is not the right one, instead I want to take the theme path. like this
<?php echo $this->getThemePath()?>/css/custom.css


But the outcome of the path is then the whole php code.
<link href="<?php echo $this->getThemePath()?>/css/custom.css" rel="stylesheet">


I'm a little confused about how to get mobile detect to work with c5. Is mobile detect loaded correctly and how do i load the theme path before /css/custom.css and /css/mobile.css

 
Remo replied on at Permalink Reply
Remo
why don't you use the built-in mobile detection? If you open the themes screen in the dashboard, you can see that you can specify an additional theme for mobiles at the very bottom of the screen.

That should do the trick!
Resonate replied on at Permalink Reply
because it already has a mobile page with CSS, and I just need to be able to change css depending on whether it is a desktop or handheld.

But can I customize it so it is only the header there is difference?

Otherwise if the client make a change in the content they have to do it on both sites, desktop and mobile? or?
Remo replied on at Permalink Best Answer Reply
Remo
Just use the built-in library

Loader::library('3rdparty/mobile_detect');
$md = new Mobile_Detect();
if ($md->isMobile()) {
...
Resonate replied on at Permalink Reply
Ok that works :)Thanke you..
Is there a way to make the css path dynamic?