Здравствуйте. Имеется opencart 3.
В левом меню категорий у меня на данный момент выводятся только категории первого уровня, без вложенных подкатегорий. Нашел код, который выводит это меню:
echo "<div class=\"list-group\">
";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["categories"]) ? $context["categories"] : null));
foreach ($context['_seq'] as $context["_key"] => $context["category"]) {
echo " ";
if (($this->getAttribute($context["category"], "category_id", array()) == (isset($context["category_id"]) ? $context["category_id"] : null))) {
echo "
<a href=\"";
echo $this->getAttribute($context["category"], "href", array());
echo "\" class=\"list-group-item active\">";
echo $this->getAttribute($context["category"], "name", array());
echo "</a>
";
if ($this->getAttribute($context["category"], "children", array())) {
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable($this->getAttribute($context["category"], "children", array()));
foreach ($context['_seq'] as $context["_key"] => $context["child"]) {
echo " ";
if (($this->getAttribute($context["child"], "category_id", array()) == (isset($context["child_id"]) ? $context["child_id"] : null))) {
echo " <a href=\"";
echo $this->getAttribute($context["child"], "href", array());
echo "\" class=\"list-group-item active\"> - ";
echo $this->getAttribute($context["child"], "name", array());
echo "</a>
";
} else {
echo "
<a href=\"";
echo $this->getAttribute($context["child"], "href", array());
echo "\" class=\"list-group-item\"> - ";
echo $this->getAttribute($context["child"], "name", array());
echo "</a>
";
}
echo " ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['child'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
echo " ";
}
echo " ";
} else {
echo " <a href=\"";
echo $this->getAttribute($context["category"], "href", array());
echo "\" class=\"list-group-item\">";
echo $this->getAttribute($context["category"], "name", array());
echo "</a>
";
}
echo " ";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['category'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
echo "</div>
";
Как сделать вывод подкатегорий выбранной категории меню? Вот как здесь :