我有一个关于 Zend_Controller_Router 的问题。我在我的应用程序中使用了模块化结构。该应用程序建立在 Zend-Framework 之上。正常的路由是这样的:
/modulename/actionname/
因为我总是在我的模块中使用 IndexController,所以没有必要在 url 中提供它。现在我可以像这样附加参数:
/modulename/actionname/paramkey/paramvalue/paramkey/paramvalue
所以这在采埃孚是正常的,我猜。但在某些情况下,我不想在 url 中提供参数键。例如,我希望在 url 中显示博客标题。当然,这是针对 SEO 的:
/blog/show/id/6/this-is-the-blog-title
在这种情况下,blog
是模块,show
是动作。id
是一个参数,6
是我要展示的博文的 id。this-is-the-blog-title
当然是带有 id 的博文的标题6
。问题是,如果我确实assemble()
像这样使用路由器的 - 方法:
assemble(array('module' =>'blog',
'action' => 'show',
'id' => $row['blog_id'],
$row['blog_headline_de'] . '.html'));
网址导致:
blog/show/id/6/0/this-is-the-blog-title.html
如您所见, a0
已作为键插入。但我希望这个 0 被省略。我尝试使用 blogtitle 作为键,如下所示:
assemble(array('module' =>'blog',
'action' => 'show',
'id' => $row['blog_id'],
$row['blog_headline_de'] . '.html' => ''));
这导致:
blog/show/id/6/this-is-the-blog-title.html/
现在0
省略了,但最后我有斜线。
您是否有任何解决方案来获取没有0
as 键且没有结尾斜杠的 url?
问候,亚历克斯