Opencart Adds Additional TPL Scheme for Category

I am trying to customize additional page layouts and categories in Opencart 1.5.4.

I have a stage where, if I enter a route of a new category in the address bar, the new template will show how I want, but it seems that I can not register this route change in OC.

If I specify a change in the .htaccess file, the new template will load as expected, but I do not answer this question (although it works).

Addition to .htaccess (wrong method, I'm sure)

RewriteRule ^skis$ index.php?route=product/categories&path=1 [L,QSA] 

I created two new files

 /catalog/view/theme/default/template/product/categories.tpl /catalog/controller/product/categories.php 

In / catalog / controller / product / categories.php, I changed the contents to reflect the new tpl file;

 class Controllerproductcategories extends Controller { 

.

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

So, in the summary

  • If I specify rewriting in the .htaccess file, loading the layout if I do not.
  • I added a new layout in OC and selected it for the category enter image description hereenter image description here

Anyone have any ideas that I could try to get this to work correctly? I have a set of templates for creating products, categories and information pages, so I would like to do it right.

Tx in advance

Stu

+4
source share
2 answers

From what I see, you are trying to hard-code each individual template, and it will not work the way you chose, using layouts for this category. The layout is intended for placement of content on the page, but not for specifying templates.

I really created a commercial version of what you are trying to achieve, which can be found here . It allows you to create templates and assign them to one or more pages. It works for products, categories, manufacturers and information pages. It also allows you to specify a template for products under an entire category or manufacturer.

+2
source

I chose this approach at the end ... might help someone else.

 if ($this->data['heading_title'] == "Skis") { $this->template = $this->config->get('config_template') . '/template/product/categories.tpl'; } elseif ($this->data['heading_title'] == "Softgoods") { $this->template = $this->config->get('config_template') . '/template/product/category.tpl'; } elseif ($this->data['heading_title'] == "Outlet Store") { $this->template = $this->config->get('config_template') . '/template/product/category.tpl'; } else { $this->template = $this->config->get('config_template') . '/template/product/category.tpl'; } 
+5
source

All Articles