如果有人有興趣,我設法創建一個解決方案,其中包括龍門框架和訪問龍門餅乾,以確定用戶正在查看哪個佈局。 (無論是正常的如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
//------------------------
,所以我不知道這是否是正確的或建議這樣做的方式,但它的魅力。