I was wondering if it was possible to have two different product pages? On one of the pages I want it to be the normal Opencart product page but I want to build a custom product page which is used for just one of my products.
This page doesn't need to be edited inside the admin as it is always going to be the one same product all of the time.
I have tried copying the product.php/tpl files inside the catalog folder and renamed this but I can't quite seem to work out how to do it.
Can anyone help.
Thanks
Now presuming the product_id of this item is always going to be the same, what you can do is this...
In the controller\product\product.php file, find this:
Code: Select all
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/product.tpl';
}
Code: Select all
if($this->request->get['product_id'] == '123') { // If ID matches this, use this new template
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_new.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/product_new.tpl';
} else {
$this->template = 'default/template/product/product.tpl';
}
} else { // If not, use standard
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/product.tpl';
}
}
Commercial Contributions:Bulk Specials| Bulk Update Prices|Search Tyre Pro
Free Contributions: Youtube video (oc 1.5.x) | Search History Report (oc 1.5.x) | Product Filter by Category (oc 1.5.x)|Youtube Popup
More Free & commercial mods: www.fpress.com
something like this for example? (btw this is not working)
Code: Select all
if($this->request->get['product_id'] == '1' || '2')
The code you suggested worked perfectly.
However, I now require 4 different products to each have there own unique product template.
I have tried copying the code you suggested 4 times and changing the template used for each one but that only seemed to enable the last one to work and the other 3 kept the standard product template and not the unique one that I had assigned.
Any suggestions on what I need to do?
Cheers
jcsmithy wrote:Copy the product.tpl file and adjust to what you want.
Now presuming the product_id of this item is always going to be the same, what you can do is this...
In the controller\product\product.php file, find this:and change it to something like thisCode: Select all
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/product.tpl'; }
Code: Select all
if($this->request->get['product_id'] == '123') { // If ID matches this, use this new template if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_new.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/product_new.tpl'; } else { $this->template = 'default/template/product/product.tpl'; } } else { // If not, use standard 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/product.tpl'; } }
I've removed the code withing the statement, hopefully you can figure out what needs to be added, but you can use this instead:
Code: Select all
if($this->request->get['product_id'] == '1') {
// show template 1
} else if($this->request->get['product_id'] == '2') {
// show template 2
} else if($this->request->get['product_id'] == '3') {
// show template 3
} else if($this->request->get['product_id'] == '4') {
// show template 4
} else {
// show default template
}
Now, if you follow that logic, each IF statement will be checked up to the point it evaluates true, if each one comes back false, then it will use the final "else" statement - always have the last statement in place!
See how that helps
btw - if you end up needing lots more different templates for different products, you may aswell make your life easier and put in a "template selection" from within the admin. this way, rather than trying to edit code yourself, you'll just have a dropdown to choose which to use. Let me know if you want this, and we'll see if we can work something out
Jcsmithy.
Commercial Contributions:Bulk Specials| Bulk Update Prices|Search Tyre Pro
Free Contributions: Youtube video (oc 1.5.x) | Search History Report (oc 1.5.x) | Product Filter by Category (oc 1.5.x)|Youtube Popup
More Free & commercial mods: www.fpress.com
Commercial Contributions:Bulk Specials| Bulk Update Prices|Search Tyre Pro
Free Contributions: Youtube video (oc 1.5.x) | Search History Report (oc 1.5.x) | Product Filter by Category (oc 1.5.x)|Youtube Popup
More Free & commercial mods: www.fpress.com
Code: Select all
// starting my custom category view
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
if ($category_id == 81) {
$this->template = $this->config->get('config_template') . '/template/product/category_download.tpl';
} else { //default
$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
}
} else {
$this->template = 'default/template/product/category.tpl';
}
//end custom category design
anyone mind sharing what needs to be added to product controller so I can use category id in it?
this way I should be able to have custome tpl per category x
Now updated to 1.5.4.1
http://www.opencart.com/index.php?route ... on_id=2359
Wedding Invitations and Stationery by Love2print
Commercial Mods
Product Colours on Category Page
Cardsave Direct Gateway
Clear Cache
Promotional Watermarks on Images
Multiple Category / Product Templates ** Popular **
Log Failed Login Attempts
Display Eligible Coupons with Products
Twitter Feeds
Have I helped you out or saved you some time? Please donate
1. Increase Page Speed Minify Compress Cache Database Optimization (tcalp - Hunter)
http://www.opencart.com/index.php?route ... on_id=6204
2. Page Cache - Boost your site speed and Google ranking (JAY6390)
http://www.opencart.com/index.php?route ... on_id=3477
These are both excellent extensions
I would like to have 2 product pages. Category 1 will have the current opencart product page and category 2 will a similar page.
All I want is that if a product is created in category 1 - product page 1 is loaded and if a product is created in category 2 is loaded - product page 2 is loaded.
Thanks
I was try this:jcsmithy wrote:Copy the product.tpl file and adjust to what you want.
Now presuming the product_id of this item is always going to be the same, what you can do is this...
In the controller\product\product.php file, find this:and change it to something like thisCode: Select all
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/product.tpl'; }
Code: Select all
if($this->request->get['product_id'] == '123') { // If ID matches this, use this new template if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_new.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/product_new.tpl'; } else { $this->template = 'default/template/product/product.tpl'; } } else { // If not, use standard 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/product.tpl'; } }
Code: Select all
if($category_id == 62 || $category_id == 88 || $category_id == 89 || $category_id == 90 || $category_id == 91 || $category_id == 92 || $category_id == 93 || $category_id == 94 || $category_id == 95 || $category_id == 96 || $category_id == 97 || $category_id == 98 || $category_id == 99 || $category_id == 113 || $category_id == 114 || $category_id == 115 || $category_id == 116 || $category_id == 117 || $category_id == 118 || $category_id == 119 || $category_id == 120 || $category_id == 121 || $category_id == 122 || $category_id == 123 || $category_id == 124 || $category_id == 125 || $category_id == 126 || $category_id == 127 || $category_id == 128 || $category_id == 129 || $category_id == 130 || $category_id == 131 || $category_id == 132 || $category_id == 133 || $category_id == 134){
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/adler.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/adler.tpl';
} else {
$this->template = 'default/template/product/product.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/product.tpl';
}
}
Undefined variable: category_id in /data/web/virtuals/27798/virtual/www/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 489
Can anyone help me pls? Thanks!
Can this be applied to a manufacturer code so that 1 particular manufacturer has a different product layout to the other product pages?jcsmithy wrote:Copy the product.tpl file and adjust to what you want.
Now presuming the product_id of this item is always going to be the same, what you can do is this...
In the controller\product\product.php file, find this:and change it to something like thisCode: Select all
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/product.tpl'; }
Code: Select all
if($this->request->get['product_id'] == '123') { // If ID matches this, use this new template if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product_new.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/product_new.tpl'; } else { $this->template = 'default/template/product/product.tpl'; } } else { // If not, use standard 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/product.tpl'; } }
Thanks.
Thanks,
James
if($this->request->get['product_id'] == '1') {
// show template 1
} else if($this->request->get['product_id'] == '2') {
// show template 2
} else if($this->request->get['product_id'] == '3') {
// show template 3
} else if($this->request->get['product_id'] == '4') {
// show template 4
} else {
// show default template
}
Users browsing this forum: Bing [Bot], Google [Bot] and 332 guests