This is a hot topic in this days and I need to build a template based on jQuery Mobile for my site. Build the template isn't the problem but show when someone navigate trough mobile devices is. I know I need to change some codes in OC core in order to do that but need some advice or help on this. First the place where the template is loaded is /system/engine/controller.php. This is the function:
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 . '!');
}
}
Ok, I manage in how to deal to check if User Agent is Mobile Device or not and this is the result:
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 . '!');
}
}
Now when I try to acces using a Mobile User Agent I get this error:
D:\Webserver\htdocs\portal/catalog/view/theme/libcommerce_mobile/Warning: require(D:\Webserver\htdocs\portal\catalog\view\theme\libcommerce_mobile) [function.require]: failed to open stream: Permission denied in D:\Webserver\htdocs\portal\system\engine\controller.php on line 77 Fatal error: require() [function.require]: Failed opening required 'D:\Webserver\htdocs\portal/catalog/view/theme/libcommerce_mobile/' (include_path='.;D:\Webserver\php\PEAR') in D:\Webserver\htdocs\portal\system\engine\controller.php on line 77
But surprise the directory exists and it's readable, any help on this? What I'm doing wrong? Cheers one more time
PS: Coming from this topic posted here http://forum.opencart.com/viewtopic.php?f=20&t=47124