I would like to create page specific template files for opencart 2.0.1.1 using the "location" field. I would like to know can this work with seo url's I have found this at the bottom of the header.php for opencart 2.0.1.1
// For page specific css
if (isset($this->request->get['route'])) {
if (isset($this->request->get['product_id'])) {
$class = '-' . $this->request->get['product_id'];
} elseif (isset($this->request->get['path'])) {
$class = '-' . $this->request->get['path'];
} elseif (isset($this->request->get['manufacturer_id'])) {
$class = '-' . $this->request->get['manufacturer_id'];
} else {
$class = '';
}
$data['class'] = str_replace('/', '-', $this->request->get['route']) . $class;
} else {
$data['class'] = 'common-home';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/common/header.tpl', $data);
} else {
return $this->load->view('default/template/common/header.tpl', $data);
}
I believe this to be the code structure for page specific css only I want to change page specific .tpl files. I would like to use a switch control method, I will using at least 5 templates for different products. Something like this example below from opencart 1.5x. would be perfect
OpenCart - View alternate product template based on arbitrary product field
Took a long time but Solved this issue here is the code for others to use "free"
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_'.$product_id.'.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product_'.$product_id.'.tpl', $data));
} elseif (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/product/product.tpl', $data));
}
/* Explanation : 1. The code will search spesific template based on it ID. ex: product_18.tpl. 2. If the spesific template is not available, Opencart will use the general template of active theme (product.tpl). 3. If the template of spesific theme is not available, Opencart will use template from default theme. */
For VQ mods using product tpl add /product_*