I have the following tables category and category_description in php mysql. my question is how with the information below do i go about creating an unlimited amount of subcategories in a ul li structure. I have looked at various examples on here but no no avail many thanks for your time in reading this question. i look forward to your response
Column Type Null Default
category_id int(11) No
image varchar(255) Yes NULL
parent_id int(11) No 0
top tinyint(1) No
column int(3) No
sort_order int(3) No 0
status tinyint(1) No
date_added datetime No 0000-00-00 00:00:00
date_modified datetime No 0000-00-00 00:00:00
And the descriptions are stored in this table
Column Type Null
category_id int(11) No
language_id int(11) No
name varchar(255) No
description text No
meta_description varchar(255) No
meta_keyword varchar(255) No
opencart has the
$this->model_catalog_category->getCategory()method, and you pass the category id as a parameter, such as
$category = this->model_catalog_category->getCategory(5);That also handles the appropriate description join too so you don’t need to access them directly. As @Till Helge Helwig has already pointed out, you need to use a recursive function if you want to build a tree of these with all the subcategories. A good place to see an example of this is in the actual category module code. Scroll to the bottom of the file
catalog/controller/module/category.phpand you will see a recursive function that builds the html for it