Post by maffu » Tue Dec 17, 2013 11:34 pm

I've found this free ext very cool, but i need to apply to category page.
any ideas?

http://www.opencart.com/index.php?route ... load_id=32

Newbie

Posts

Joined
Thu Dec 12, 2013 4:45 pm

Post by creativejack » Wed May 13, 2015 4:45 pm

Qphoria wrote:I'll show you a very easy and cool dynamic way to do this:

Edit: catalog/controller/product/category.php

Find:

Code: Select all

$this->template = $this->config->get('config_template') . 'product/category.tpl';
Replace with:

Code: Select all

$this->template = $this->config->get('config_template') . 'product/category_' . $this->request->get['path'] . '.tpl';
if (!file_exists(DIR_TEMPLATE . $this->template)) {
	$this->template = $this->config->get('config_template') . 'product/category.tpl';
}
Now, anytime you want a custom category template. Create a clone of the category.tpl file using the category path as part of the name. For example:

category_25.tpl
category_25_38.tpl
category_25_38_72.tpl
etc.

The code will first check for the existence of an override file. If there is one it will use it. If there is none for that category, then it will default to the original file.

This can be done for virtually any file. Products, information, etc.
Is this possible to recreate in opencart 2? struggling to find a solution

Newbie

Posts

Joined
Fri May 10, 2013 9:44 pm

Post by jsdfwwe3122 » Thu Mar 16, 2017 3:04 am

I wanted this functionality, so I found a solution for opencart v2.3.0.2. I thought I would post it in case anyone else needs this:

In catalog/controller/product/category.php

find this line:

Code: Select all

$this->response->setOutput($this->load->view('product/category', $data));

replace with this:

Code: Select all

if (file_exists(DIR_TEMPLATE . 'default/template/product/category_' . $this->request->get['path'] . '.tpl')) {
	$this->response->setOutput($this->load->view('product/category_' . $this->request->get['path'], $data));
}
else {
	$this->response->setOutput($this->load->view('product/category', $data));
}

Newbie

Posts

Joined
Tue Feb 21, 2017 2:50 am
Who is online

Users browsing this forum: Alexa [Bot] and 15 guests