Zend_Navigation: kontrolörün tüm eylemleri etkin duruma nasıl uygulanacağı?

1 Cevap php

Biz var, diyelim ki:

$pages = array(
    array(
        'controller' => 'controller1',
        'label'      => 'Label1',
    ),
    array (
        'controller' => 'controller2',
        'label'      => 'Label2'
    ),
);
$container = new Zend_Navigation($pages);

When user clicks Label1, controller1/index action is rendered and Label1 becomes active state - everything is ok. On this page I have many links, such as: controller1/action1, controller1/action2, etc When one of these links is clicked, Label1 looses active state.

Ben Zend_Navigation içine tüm alt sayfaları ekleyebilirsiniz, anlıyorum, ama bu sayfalarda bol ve ben gibi bir şey olmasını tercih ederim, navigasyon için her yerde gerek, bu yüzden asla:

public function init()
{
    $this->view->navigation()-> ... get item by label ... -> setActive();
}

controller1 içeride. Bu mümkün mü?

1 Cevap

Sizin init yöntemi çok yakın!

$page = $this->view->navigation()->findOneByLabel('Your Label'); /* @var $page Zend_Navigation_Page */
if ( $page ) {
  $page->setActive();
}