S
S
Sergey Virchenko2016-03-24 00:20:24
PHP
Sergey Virchenko, 2016-03-24 00:20:24

How to define category, subcategory and product page in Opencart?

There is a task for 3 types of pages (category, subcategory, product) to generate title and description and h1 according to 3 templates, respectively. I decided to check in the head and display the appropriate template for the corresponding page type, but I don’t know how to determine which page is which (NC, i.e. category - mysite.ru/cat-1, subcategory - mysite.ru/cat-1/podcat -1, product page - mysite.ru/cat-1/prod-1 (yes, that's right)). Prompt solution

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Arutyunov, 2016-03-24
@arutyunov

Despite the fact that you have CNC enabled, in the request class Opencart stores __path__ in the form 54_57, where 54 is the id of the parent category, 57 is the child category.
Do you have CNC from seo-pro?
Look at the seo-pro class, you will see how it works with path.
The second way is to check if the current category has a parent_id. If there is, then the category is a child, if not, then the category is the parent.
And the product page has its own separate template.

E
Egor, 2016-03-24
@egormmm

Categories are stored in $this->request->get['path']the form category_subcategory (1_12).
And the product page can be found at:
isset($this->request->get['product_id'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question