public function getLevelContainer($level, Item $baseItem = null)
    {
        // define if the requested level is the root line (level 1) or not
        $rootLine = ($level === 1) ? true : false;
        // countdown the level (as we need the parent of the element to get the children
        $level--;
        // foreach counter
        $i = 1;
        
        if ($baseItem === null) {
            $baseItem = $this->getCurrent();
        }
        
        // foreach
        foreach ($baseItem->with('hidden')->getTeardown() as $item) {
            // if its the root line an match level 1 get all siblings
            if ($rootLine && $i == 1) {
                return $item->without(['hidden'])->siblings;
            } elseif ($i == $level) {
                return $item->without(['hidden'])->children;
            }
            $i++;
        }
        // no no container found for the defined level
        return [];
    }
public function getLevelContainer($level, Item $baseItem = null)
    {
        // define if the requested level is the root line (level 1) or not
        $rootLine = ($level === 1) ? true : false;
        // countdown the level (as we need the parent of the element to get the children
        $level--;
        // foreach counter
        $i = 1;
        
        if ($baseItem === null) {
            $baseItem = $this->getCurrent();
        }
        
        // foreach
        foreach ($baseItem->with('hidden')->getTeardown() as $item) {
            // if its the root line an match level 1 get all siblings
            if ($rootLine && $i == 1) {
                return $item->without(['hidden'])->siblings;
            } elseif ($i == $level) {
                return $item->without(['hidden'])->children;
            }
            $i++;
        }
        // no no container found for the defined level
        return [];
    }
public function getLevelContainer ( $ level , Item $ baseItem = null ) { // define if the requested level is the root line (level 1) or not $ rootLine = ( $ level === 1 ) ? true : false ; // countdown the level (as we need the parent of the element to get the children $ level -- ; // foreach counter $ i = 1 ; if ( $ baseItem === null ) { $ baseItem = $ this -> getCurrent ( ) ; } // foreach foreach ( $ baseItem -> with ( 'hidden' ) -> getTeardown ( ) as $ item ) { // if its the root line an match level 1 get all siblings if ( $ rootLine && $ i == 1 ) { return $ item -> without ( [ 'hidden' ] ) -> siblings ; } elseif ( $ i == $ level ) { return $ item -> without ( [ 'hidden' ] ) -> children ; } $ i ++ ; } // no no container found for the defined level return [ ] ; }
Get all items for a specific level.

@param integer $level Define the level you like to get the items from, the hirarchy starts by the level 1, which is the root line.
@param \luya\cms\menu\Item $baseItem Provide an optional element which represents the base calculation item for Theme
siblings/children calculation, this can be case when you have several contains do not want to use the "current" Item
as base calucation, because getCurrent() could be in another container so it would get you all level container items for
this container.
@return array|\luya\cms\menu\QueryIterator All siblings or children items, if not found an empty array will return.
Get all items for a specific level .