Different product template based on location (or any field)
Posted: Fri Aug 09, 2013 1:28 am
I am looking to have different product templates for a couple product types. Feature products will have product.tpl and Accessories will have accessory.tpl.
I know I can designate templates in the controller by using IDs
But I was wondering if I can use an arbitrary product field instead of the ID. For example, I could enter "accessory" in the location field of a product and that would automatically load the accessory.tpl.
I know I can designate templates in the controller by using IDs
Code: Select all
//42 is the id of the product
if($this->request->get['product_id'] == 42){
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/customproduct.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/customproduct.tpl';
} else {
$this->template = 'default/template/product/customproduct.tpl';
}
}
else{
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/product.tpl';
} else {
$this->template = 'default/template/product/customproduct.tpl';
}
}