使用Zend_Config_XML的Zend Framework路由

时间:2010-01-16 17:40:53

标签: zend-framework zend-route

我需要将现有的routes.ini文件转换为XML文件(我的主机禁用了PHP的parse_ini)。无论如何,我找不到合适的例子,所以我尝试使用传统的Zend_Config_XML结构。见下文:

<?xml version="1.0"?>
<configdata>
 <routes>
  <Home route=":locale/">
   <defaults controller="index" action="index" locale="tr_TR"/>
  </Home>
 </routes>
 <routes>
  <NewsList route=":locale/news-list/:pageID">
   <defaults controller="index" action="newsList" locale="tr_TR"/>
  </NewsList>
 </routes>
<configdata>

然而它没有用;上面的例子说“NewsList”路线不存在。我在官方文档中找到了一些例子,但它们也没有帮助。

有人可以协助正确的XML结构吗?

谢谢, 戈克钦

1 个答案:

答案 0 :(得分:2)

<?xml version="1.0"?>
<configdata>
  <routes>
      <Home route=":locale/">
          <defaults controller="index" action="index" locale="tr_TR"/>
      </Home>
      <NewsList route=":locale/news-list/:pageID">
          <defaults controller="index" action="newsList" locale="tr_TR"/>
      </NewsList>
  </routes>
<configdata>

我认为你不应该使用两个单独的路由标签,将这两个规则包装在一起。