Categories
Cool Stuff Dreamweaver eCommerce Guides HTML opencart opencart 1.5 OpenCart Themes

Custom Category Templates and CSS in OpenCart 1.5 +

Custom Category Templates and Custom Category CSS for OpenCart relates to the following tested versions:

OpenCart version(s):  1.5.0, 1.5.0.1, 1.5.0.2, 1.5.0.3, 1.5.0.4, 1.5.0.5

> Newly tested on OpenCart 1.5.1.1 and works

This was tested today on OpenCart v 1.5.0.5 today and was working flawlessly.

Ever wanted to have a custom category template (hard coded elements) On certain categories – or to totally change the layout completely?  Or maybe you’d just like different CSS?

These instructions relate to the default theme of OpenCart but should work for any theme provided you change the default bit with the themes name!

Open: catalog/controller/product/category.php

Find (Line 329):

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
} else {
$this->template = 'default/template/product/category.tpl';
}

Replace With:

//start custom category design by ItsAdam.co.uk
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
if ($category_id == 1) { //Category 1
$this->template = $this->config->get('config_template') . '/template/product/category1.tpl';
} elseif ($category_id == 2) { //Category 2
$this->template = $this->config->get('config_template') . '/template/product/category2.tpl';
} elseif ($category_id == 3) { //Category 3
$this->template = $this->config->get('config_template') . '/template/product/category3.tpl';
} elseif ($category_id == 4) { //Category 4
$this->template = $this->config->get('config_template') . '/template/product/category4.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

For our new custom categories we will need to create the templates so that they’re viewable and custom.

Find: catalog/view/theme/product/category.tpl

And duplicate it and name it inline with the naming in the above code, ie category1.tpl etc etc

This OpenCart Mod is published for free to the Community, if you require more extensive modifications or OpenCart Themes, contact by email:

opencart at itsadam.co.uk

Sorry for the anti-spam measure, I get lots of traffic and even more spam 🙁

New! Download these instructions in plain text format (handy if you copy and paste and it’s not working or wordpress ignores the code tag).

Download the Instructions in Plain Text Format

Leave a Reply

Your email address will not be published. Required fields are marked *