Model view controller 为什么Zend将子页面标记为处于活动状态?
我在使用Zend_导航设置面包屑和菜单时遇到问题 首先,我使用XML配置对象设置页面:Model view controller 为什么Zend将子页面标记为处于活动状态?,model-view-controller,zend-framework,zend-navigation,Model View Controller,Zend Framework,Zend Navigation,我在使用Zend_导航设置面包屑和菜单时遇到问题 首先,我使用XML配置对象设置页面: <?xml version="1.0" encoding="UTF-8"?> <configdata> <nav> <home> <label>Home</label> <controller>Index</controller> <action>
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>Index</controller>
<action>index</action>
<id>home</id>
<resource>default</resource>
</home>
<crm>
<label>CRM</label>
<module>Crm</module>
<controller>Index</controller>
<action>index</action>
<id>crm</id>
<resource>Crm</resource>
<pages>
<persons>
<module>Crm</module>
<label>Personen</label>
<controller>Persons</controller>
<action>index</action>
</persons>
(...)etc.(...)
现在如果我要导航到http://hostname/Crm/Persons/
活动状态将正常工作,面包屑也将正确显示
但是,当我转到http://hostname/Crm/Persons/inspect/id/3
(其中inspect是操作,id是参数)面包屑将为空,并且没有任何菜单项处于活动状态。预期的面包屑类似于:Home>CRM>Personen>John
,并且CRM和Personen应该在菜单中处于活动状态
现在Zend文档给了我一个线索:由于设置了参数,它可能无法工作
/*
* Dispatched request:
* - module: blog
* - controller: post
* - action: view
*/
$page = new Zend_Navigation_Page_Mvc(array(
'action' => 'view',
'controller' => 'post',
'module' => 'blog',
'params' => array('id' => null)
));
// returns false, because page requires the id param to be set in the request
$page->isActive(); // returns false
但我不知道如何解决这个问题。非常感谢您的想法。我以前没有使用xml文件在ZF中设置导航,所以我不确定这是否可行。但根据我的经验,在您的个人标签上添加以下内容:
<params>
<id>0</id>
</params>
0
在本例中,默认情况下,id设置为0
请参见经过一些(大量)修改,我发现我需要在XML中定义页面,Zend才能识别该结构
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>Index</controller>
<action>index</action>
<id>home</id>
<resource>default</resource>
</home>
<crm>
<label>CRM</label>
<module>Crm</module>
<controller>Index</controller>
<action>index</action>
<id>crm</id>
<resource>Crm</resource>
<pages>
<persons>
<module>Crm</module>
<label>Personen</label>
<controller>Persons</controller>
<action>index</action>
<pages>
<inspect> <--- this will make Zend recognize the page
<module>Crm</module>
<label>Persoon</label>
<controller>Persons</controller>
<action>inspect</action>
</inspect>
</pages>
</persons>
(...)etc(...)
家
指数
指数
家
违约
客户关系管理
客户关系管理
指数
指数
客户关系管理
客户关系管理
客户关系管理
叫做人身
珀森斯
指数
我担心这不起作用(因为它将在索引上设置一个ID
操作)。请将您的解决方案作为答案发布。是的,我试过了,但不让我:(我现在就做!但是这需要您将每个控制器的每个操作设置为导航配置文件中的一个页面。
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>Index</controller>
<action>index</action>
<id>home</id>
<resource>default</resource>
</home>
<crm>
<label>CRM</label>
<module>Crm</module>
<controller>Index</controller>
<action>index</action>
<id>crm</id>
<resource>Crm</resource>
<pages>
<persons>
<module>Crm</module>
<label>Personen</label>
<controller>Persons</controller>
<action>index</action>
<pages>
<inspect> <--- this will make Zend recognize the page
<module>Crm</module>
<label>Persoon</label>
<controller>Persons</controller>
<action>inspect</action>
</inspect>
</pages>
</persons>
(...)etc(...)