WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
<?phpif (isMobile()) { include('mobile.php'); return;}?>
<?php $template = isMobile() ? '/mobile.css' : '/maintemplate.css'; ?> <link rel="stylesheet" type="text/css" href="<?php echo TEMPLATE_DIR.$template; ?>" media="screen" />
-------------- I'm trying to put ismobile check here<?php/**/if(!defined('WB_URL')) { header('Location: ../index.php'); exit(0);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title><?php page_title(); ?> <?php echo WEBSITE_TITLE; ?></title><meta http-equiv="Content-Type" content="text/html; charset=<?php if(defined('DEFAULT_CHARSET')) { echo DEFAULT_CHARSET; } else { echo 'utf-8'; }?>" /><meta name="description" content="<?php page_description(); ?>" /><meta name="keywords" content="<?php page_keywords(); ?>" />
<?phpif (isMobile()) { die("Mobile detected");}?>
This is a correct way.Doing it this way, you must use your mobile.php exactly the same as your index.php.A quick check to see if the snippet is functioning use something likeCode: [Select]<?phpif (isMobile()) { die("Mobile detected");}?>It should just display the text "Mobile detected" (when you use a mobile browser) and nothing else.
<?phpif (isMobile() || isIpad()) { include('mobile.php'); return;}?>
To support all mobiles and tablets a responsive layout is the best solution
This script detects several different divices. How many different website sizes (stylesheets) do you need to make?
That should be possible..Something like: using a codepage to display the "question" if isMobile() is true. Redirect to a homepage if isMobile() is false.In the template you can test for a GET parameter (index.php?showmobile=1) and set a $_SESSION for the future pages template to use.Code: (untested) [Select]<?phpif (isMobile()) {echo '<a href="/pages/home.php?showmobile=1">Mobile site</a> | <a href="/pages/home.php">Normal site</a>';} else {echo '<a href="/pages/home.php">To the website</a>';}?>in the template:Code: (untested) [Select]<?php if (isset($_GET['showmobile'] && $_GET['showmobile'] == 1) { $_SESSION['css'] = 'mobile.css';} elseif (!isset($_SESSION['css'])) { $_SESSION['css'] = 'normal.css';}?>Link your stylesheet with <?php echo $_SESSION['css']; ?>
<?phpif (isMobile()) {echo '<a href="/pages/home.php?showmobile=1">Mobile site</a> | <a href="/pages/home.php">Normal site</a>';} else {echo '<a href="/pages/home.php">To the website</a>';}?>
<?php if (isset($_GET['showmobile'] && $_GET['showmobile'] == 1) { $_SESSION['css'] = 'mobile.css';} elseif (!isset($_SESSION['css'])) { $_SESSION['css'] = 'normal.css';}?>
<a href="?showmobile=1">Mobile site</a>
<?php // create linksecho '<a href="?mobile">Mobile site</a> | <a href="?web">Normal site</a>';?>
<?php// test what stylesheet should be usedif (isset($_GET['mobile'])) $_SESSION['css'] = 'mobile.css';if (isset($_GET['web'])) $_SESSION['css'] = 'normal.css';// if a stylesheet was not set yetif (!isset($_SESSION['css'])) $_SESSION['css'] = 'normal.css';?>
<link href="<?php echo TEMPLATE_DIR; ?>/<?php echo $_SESSION['css']; ?>" rel="stylesheet" type="text/css" />
<?php$mobile = isMobile(); // check if the visitor uses mobile device (for first visit)if (isset($_SESSION['mobile'])) $mobile = $_SESSION['mobile']; // check if previous mobile was usedif (isset($_GET['mobile'])) $mobile = true; // check if user wants mobile viewif (isset($_GET['web'])) $mobile = false; // check if user wants normal view$_SESSION['mobile'] = $mobile; // store view setting for next page loadingif ($mobile) { // if mobile is wanted/needed use other php template include ('mobile.php'); return;}?>
If I include this code on the index.php template (normal site) it will ask the question about which version you want to see even if you visit from a desktop PC which obviously shouldn't happen.
<?php //colored$touch = (isSmartPhone() || isTablet());if(!$touch){ do this ...} else { do that ...} ?>