Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
This is the place for questions about learning design and pedagogy; how to use different page types for different purposes.
  • Page:
  • 1

TOPIC:

using php in Xerte 4 years 3 months ago #6215

  • rloenen
  • rloenen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 94
  • Thank you received: 0
Sometimes I want to use php to detect the type of device to forward to another site. How is that possible in Xerte?
Ronald

Please Inloggen or Create an account to join the conversation.

using php in Xerte 4 years 3 months ago #6217

  • tom
  • tom's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 1290
  • Thank you received: 308
You cannot use php for that in Xerte. A Xerte LO is purely client-side based, so you would need to accomplish the same in javascript.

Wat kind of devices would you like to be able to detect?

Please Inloggen or Create an account to join the conversation.

using php in Xerte 4 years 3 months ago #6218

  • rloenen
  • rloenen's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 94
  • Thank you received: 0
Some lo's are specially made for a mobile and have a different version for laptops. This has to do with the size of images and tables or too many tabs for a mobile to keep a clear screen.
I have solved this by the opening off my site and immediately detect what the device is and from there to go to other menu pages that again refer to other lo's.
So it is solved.
For them who want to know how I did it the script. It seems to work well so far
vo-xerte.php is my menusite
vo-xerte_m.php is my menusite for mobiles.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>soort device</title>
</head>

<body>
<?php
function checkDevice() {
// checkDevice() : checks if user device is phone, tablet, or desktop
// RETURNS 0 for desktop, 1 for mobile, 2 for tablets

if (is_numeric(strpos(strtolower($_SERVER), "mobile"))) {
return is_numeric(strpos(strtolower($_SERVER), "tablet")) ? 2 : 1 ;
} else {
return 0;
}
}

$deviceType = checkDevice();
if ($deviceType==0) {
header('Location: vo-xerte.php');
} else if ($deviceType==1) {
header('Location: vo-xerte_m.php');
} else {
header('Location: vo-xerte.php');
}
?>
</body>

</html>

Please Inloggen or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ingdon
Time to create page: 0.047 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search