Rendering Active Branch of Zend Navigation Without Top Level

后端 未结 3 828
刺人心
刺人心 2021-01-15 12:50

I am rendering the top-level elements of a Zend Navigation object in one place like this:

echo $this->navigation()->menu()->setMaxDepth(0);
<         


        
3条回答
  •  -上瘾入骨i
    2021-01-15 13:50

    I do it this way:

    navigation()->menu()->setMaxDepth(0);
    
    // Render 2nd level elements for active element
    echo $this->navigation()->menu()
            ->setOnlyActiveBranch(true)
            ->setRenderParents(false)
            ->setMinDepth(1);
    
    ?>
    

    but this is not a good solution. Better one for each level as a separate menu:

    
    navigation()->menu()->setMaxDepth(0); ?>
    
    
    
    navigation()->menu()->setOnlyActiveBranch(true)->setRenderParents(true)->setMinDepth(1)->setMaxDepth(1); ?>
    
    
    
    
    navigation()->menu()->setOnlyActiveBranch(true)->setRenderParents(false)->setMinDepth(2)->setMaxDepth(2); ?>
    

提交回复
热议问题