这是当今的热门话题,我需要为我的网站构建一个基于 jQuery Mobile 的模板。构建模板不是问题,但当有人通过移动设备导航时显示是问题。我知道我需要更改 OC 核心中的一些代码才能做到这一点,但需要一些建议或帮助。首先加载模板的地方是/system/engine/controller.php。这是功能:
protected function render() {
foreach ($this->children as $child) {
$this -> data[basename($child)] = $this -> getChild($child);
}
if (file_exists(DIR_TEMPLATE . $this -> template)) {
extract($this -> data);
ob_start();
require (DIR_TEMPLATE . $this -> template);
$this -> output = ob_get_contents();
ob_end_clean();
return $this -> output;
} else {
exit('Error: Could not load template ' . DIR_TEMPLATE . $this -> template . '!');
}
}
好的,我管理如何处理以检查用户代理是否是移动设备,结果如下:
protected function render() {
foreach ($this->children as $child) {
$this -> data[basename($child)] = $this -> getChild($child);
}
//--------- ADDED -------------------------------------------------
if ($this -> config -> get('mobile_status') == 1) {
if (($this -> isMobile() && $this -> config -> get('autodetect') == 'true') || $this -> session -> data['ismobile'] == 1) {
$mobile_template = $this -> config -> get('mobile_template_name');
if ($mobile_template != '') {
if (!function_exists('is_dir') || (function_exists('is_dir') && is_dir(DIR_TEMPLATE . $mobile_template))) {
$this -> template = $mobile_template . "/";
}
}
}
}
//--------- ADDED -------------------------------------------------
if (file_exists(DIR_TEMPLATE . $this -> template)) {
extract($this -> data);
ob_start();
require (DIR_TEMPLATE . $this -> template);
$this -> output = ob_get_contents();
ob_end_clean();
return $this -> output;
} else {
exit('Error: Could not load template ' . DIR_TEMPLATE . $this -> template . '!');
}
}
现在,当我尝试使用移动用户代理访问时,我收到此错误:
D:\Webserver\htdocs\portal/catalog/view/theme/libcommerce_mobile/警告:需要(D:\Webserver\htdocs\portal\catalog\view\theme\libcommerce_mobile)[function.require]:无法打开流:权限在第 77 行的 D:\Webserver\htdocs\portal\system\engine\controller.php 中被拒绝 致命错误:require() [function.require]: 无法打开所需的 'D:\Webserver\htdocs\portal/catalog/view/第 77 行 D:\Webserver\htdocs\portal\system\engine\controller.php 中的主题/libcommerce_mobile/' (include_path='.;D:\Webserver\php\PEAR')
但是令人惊讶的是目录存在并且它是可读的,对此有什么帮助吗?我做错了什么?再喝一次
PS:来自这里发布的这个主题http://forum.opencart.com/viewtopic.php?f=20&t=47124