【发布时间】:2012-03-16 17:27:34
【问题描述】:
我在从移动页面转到 Joomla 1.5 中实现的主页时遇到问题。 我正在使用位于 http://code.google.com/p/php-mobile-detect/
的 PHP Mobile Detect 脚本首先我在一个简单的网站(不是 Joomla)中测试了我的脚本。 这是实际使用的代码(index.php):
<?php
session_start();
include("Mobile_Detect.php");
$mobile_detect = new Mobile_Detect();
if (isset($_GET['ua']) && $_GET['ua']==1){
$_SESSION['sitemode'] = 1;
}elseif (isset($_GET['ua']) && $_GET['ua']==0){
unset($_SESSION['sitemode']);
}
if ($mobile_detect->isMobile() && !isset($_SESSION['sitemode'])) {
// any mobile platform
header('Location: mobile/');
}
// site related codes goes here...
?>
因此,当使用移动设备访问该网站时,它将重定向到移动网站(wwwroot 中的子文件夹)。在移动网站中,用户可以通过提供的链接(在 mobile/index.php 中)选择使用主网站:
<a href="../index.php?ua=1">Fullsite</a>
在移动页面中也启用了会话。
然后,在主页面中,用户可以浏览到主网站的其他页面,而不会被重定向到移动页面。这在以根目录中的 index.php 作为引导程序的独立 php 脚本上完美运行。
但是,当我尝试在 Joomla 中实现它时,它只适用于第一个重定向。当我浏览到 Joomla 站点中的其他页面时,它会重定向到移动页面。上面的脚本是在Joomla的bootstrap(index.php)顶部添加的
谢谢!
【问题讨论】: