Exclude some Category in tree

Dear all,
I have problem with category tree, because when I open Category, on left side I have dropdown list and I have same name of primary category. I try to hide or exclude primary category, just show other category in this dropdown list.
This is part of code in my controller:

public function actionKancelarijskiMaterijal($category_id = 4)
    $kategorije = Catalog::tree();
    $podkategorije = Category::find()->where(['tree'=>4])->all();
    $request = Yii::$app->request;
    $filters = $request->post();
    //echo '<pre>';print_r($filters);print_r($_POST);exit;
    //if ($filters) {
        $fieldFilter = [];
        foreach ($filters as $key => $value) {
            if ($key == '_csrf')

            $filterItem = [];
            $filterOptions = $filters[$key];
            $filterTitle = $key;
            //echo $filterTitle.'----';
            $options = [];
            //echo '<pre>';print_r($filterOptions);exit;
            //if (count($filterOptions) > 0) {
                foreach($filterOptions as $key1 => $value1){
                    $options[] = $value1;//$filterOptions[$key1];
            $filterItemOptions[] = $options;
            //$filterItem[] = $filterItemOptions;
            $fieldFilter[$filterTitle] = $options;
        //echo '<pre>';print_r($fieldFilter);

    $items = Catalog::items(['where' => ['category_id' => $category_id], 'filters' => $fieldFilter]);

    $kategorija = Catalog::cat( $category_id );
    $goods = Shopcart::goods();

    return $this->render('kancelarijski_materijal',

Can anyone help for this? Number id 4 is id of my primary category and I want this id exclude in dropdown list or hide.

You could exclude them from your Query
For Example:

andWhere(['!=', 'category_id', '4'])
1 Like

Where I place that piece of code?
Is it between: Category::find()->>where([‘tree’=>4])->>all() and before ; ?

When you can provide more information?
Maybe a Database Scheme .

I used EasyiiCMS and in backend I have tree where Kancelarijski Materijal is primary and other all is subcategory.

Dear demonking, thanks a lot. It’s working.