L
L
LoveCode &Coffe2018-09-05 20:45:51
opencart
LoveCode &Coffe, 2018-09-05 20:45:51

Where in the opencart controller is output written to a specific tpl file?

I teach opencart myself. If the question is not correct, do not scold too much). It became necessary to create a separate layout for a separate "products" page, where to display all the products available in the store. The output of all goods decided quite simply. Through the recommended module, I created a new module where I stuffed all the goods. Because I don't have enough standard layouts. Created a new layout in the admin panel. I want to edit the layout of this layout. Created a file in the
product/catolog.tpl directory.
Here now a question
That all earned the controller file is necessary. I think it's enough to copy the category.php file. But what lines in it need to be changed in order to connect my catalog.tpl file to it?
the code of the original controller does not fit into the maximum therefore https://gist.github.com/VladimirWeblife/bc0d470a2a... he is here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zoozag, 2018-09-06
@zoozag

To replace the output template
$this->response->setOutput($this->load->view('product/category', $data));
replace with
$this->response->setOutput($this->load->view('product/catalog', $data));
But there will still need to be edited in the controller.
In the recommended ones, you will have to add products manually. I would recommend a slightly different approach. Create the category Products and in the controller replace the piece of code from $filter_data to

if ($category_id == {id категории с Продукция}) {
  $filter_data = array(
    'filter_category_id' => 0,
    'filter_sub_category' => true
    'filter_filter'      => $filter,
    'sort'               => $sort,
    'order'              => $order,
    'start'              => ($page - 1) * $limit,
    'limit'              => $limit
  );
} else {
  $filter_data = array(
    'filter_category_id' => $category_id,
    'filter_filter'      => $filter,
    'sort'               => $sort,
    'order'              => $order,
    'start'              => ($page - 1) * $limit,
    'limit'              => $limit
  );
}

This will bring you to the category all products. If you want to change the template for this category, you can also display a view depending on the category id.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question