如果有人感兴趣,我设法创建了一个解决方案,其中包括龙门框架并访问龙门 cookie 以确定用户正在查看的布局。(正常的 default.php 文件或 default_phone.php)
我们开始吧:在您的 view.html.php 文件中:
//-----------------
// Add the Gantry framework and access the iphone switcher values!
//-----------------
$gantry_path = JPATH_SITE . '/libraries/gantry/gantry.php';
if (file_exists($gantry_path))
{
require_once($gantry_path);
}
else
{
echo "error " . JText::_('Unable to find Gantry library. Please make sure you have it installed.');
die;
}
global $gantry;
$prefix = 'viewswitcher-'.$gantry->get('template_prefix');
$cookiename = $prefix.$gantry->browser->platform.'-switcher';
$cookie = JRequest::getVar($cookiename, false, 'COOKIE', 'STRING');
if($cookie == true)
{
//User is viewing from iphone mode
$tpl = 'phone'; // this will call the layout file named: default_phone.php (It MUST be called default_xxx.php)
}
else{
//User is viewing from desktop - Do nothing! - view.html.php will call the normal default.php layout
}
//------------------------
// End Gantry Framework
//------------------------
所以我不确定这是否是正确或可取的方式,但它很有吸引力。