D
D
Dmitry2014-09-10 20:21:46
opencart
Dmitry, 2014-09-10 20:21:46

How to include a separate stylesheet for an OpenCart category?

Hello!
OCStore 1.5.4 It is necessary that a separate style sheet be connected for some product categories.
Moreover, you need to determine what style should be for a particular category from the admin panel.
How can such a problem be solved?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nursultan Moldobaev, 2014-09-11
@1diem

It will look something like this:
create a style category module where you can display categories and define their name style.
We create
a model

class ModelStyleCategory extends Model {
$style_categoryes = $this->db->query("SELECT * FROM " . DB_PREFIX ."setting WHERE `group` = 'style_cat'");
return $style_categoryes->rows;
}

then in header.php you can add the following code
$this->load->model('catalog/style_model');
$category_style = $this->model_catalog_style_model->
if(isset($this->request->get['path'])) {
       foreach ($category_style as $style) {
                  if ($style[category_id] == $this->request->get['path'])) {
                             $this->data['style_category'] ='<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/'.$style[name].'.css">';
}
       }
}

and in header.tpl
where the link is connected write
if (isset($style_category))  {
               echo $style_category;
        }

Something like this...

H
halfhope, 2014-09-23
@halfhope

Or you can use the module . Create a copy of category.tpl, include a css file in it, then select a category in the module.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question