unrealock Posted August 7, 2018 Report Share Posted August 7, 2018 Есть категория, в ней есть подкатегории. Необходимо вытащить только подкатегории определенной категории. категория_1 (id-136) подкатегория_2 (id-140) подкатегория подкатегория подкатегория Нужно вытащить из строго определенной категории все ее подкатегории. Решения не нашел. Пытался вызывать через условие но так и не смог. {function name=categories_tree level=0} {foreach $categories as $c} {if $c->id == 140} <ul class="prod"> {if $level!=0} <li><a href="catalog/{$cat->url}" data-category="{$cat->id}">{$c->name}</a> {/if}</ul> {/if} {if $c->subcategories} {categories_tree categories=$c->subcategories level=$level+1} {/if} {/foreach} {/function} {categories_tree categories=$categories} Quote Link to post Share on other sites
yr4ik Posted August 8, 2018 Report Share Posted August 8, 2018 в view/IndexView.php после: $this->design->assign('categories', $this->categories->get_categories_tree()); добавьте строку: $this->design->assign('categories_all', $this->categories->get_categories()); после чего сможете делать так: {if $categories_all[140]} {foreach $categories_all[140]->subcategories as $c} {$c->name} {/foreach} {/if} Quote Link to post Share on other sites
unrealock Posted August 9, 2018 Author Report Share Posted August 9, 2018 в view/IndexView.php после: $this->design->assign('categories', $this->categories->get_categories_tree()); добавьте строку: $this->design->assign('categories_all', $this->categories->get_categories()); после чего сможете делать так: {if $categories_all[140]} {foreach $categories_all[140]->subcategories as $c} {$c->name} {/foreach} {/if} Спасибо! Все заработало. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.