Zend_Navigation:如何使动态添加的页面保存为其他操作


Zend_Navigation : how to make dynamically added page saved for other actions?

我正在使用Zend_Navigation为100+参考的购物网站工作。导航栏有一些静态页面,比如"产品"页面。有些页面是动态创建的,例如,当用户转到产品页面时,在产品操作中创建导航页面:

$pageToAdd = array (
    'label' => 'Product 01',
    'controller' => 'productController',
    'action' => 'productAction'
);
$this->view->navigation()->findByLabel('Products');

这很好。然后,对于每个产品,用户可以获得另一个页面,其中包含与该产品相关的选项,我想在前面创建的页面上添加另一个页面。因此,在'options-product'操作中,我做了同样的事情:

$pageToAdd = array (
    'label' => 'Option for product 01',
    'controller' => 'productController',
    'action' => 'optionsProductAction'
);
$this->view->navigation()->findByLabel('Product 01');

但是此时,前一页('Product 01')在导航中不再存在。它只包含静态页面"Products",我找不到如何在两个操作之间"保存"导航。

navigation集装箱不自救

轻松工作的最快方式

从您的动作控制器的preDispatch()方法的req参数中查找productId id。如果存在-添加到Zend_Navigation实例的正确产品页面链接