Answer the question
In order to leave comments, you need to log in
Why are there no child categories in the open-cart 2 category module?
Good afternoon.
For the first time I work with open-cart, I just pass the course.
In the header in the menu, I displayed a list of categories from the $categories array, and there I also displayed subcategories from $category['children'].
Now in the sidebar in $column_left I added a category module.
In the category.tpl file from the theme folder -> template -> extenstion -> module, I go through the $categories array, but the $category['children'] element has an empty array.
Maybe somewhere else you need to add a setting so that child categories are also displayed?
Code from category.tpl
<div class="col-xs-6 col-md-12">
<div class="widget">
<h3><?php echo $heading_title; ?></h3>
<ul>
<?php foreach($categories as $category): ?>
<li>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php if($category['children']): ?>
<ul class="subcat">
<?php foreach($category['children'] as $child): ?>
<li> - <a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div><!-- .widget -->
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question