Symfony路由URL工作但其错误

时间:2014-01-24 20:10:04

标签: php symfony1 symfony-1.4

我有以下内容我在routing.yml有以下设置:

show_collection:
  url:   /:module/collection/:collection
  class:   sfDoctrineRoute
  options: { model: Category, type: object }
  param: { module: collection, action: showcollection }

collection:
  url:   /collection/
  param: { module: collection, action: index }

链接正常工作,但有一个问题。链接是这样的:

frontend_dev.php/collection/showcollection/collection/{name of collection}

所以它正在制作/ module / action / module / name_of_collection。 我需要的是:

 frontend_dev.php/collection/showcollection/{name of collection}

即使它现在有效,它也会更有意义。我已经查看了jobeet和其他路由教程,但是我无法弄清楚出了什么问题。

提前致谢!

修改

继承人url_for:

url_for(array(
      'module' => 'collection',
      'action' => 'showcollection',
      'collection' => $collection->getName()
))

结果如下:

  .../collection/showcollection/collection/{collection Name}

1 个答案:

答案 0 :(得分:2)

尝试将路线更改为:

show_collection:
  url:   /:module/:action/:collection
  class:   sfDoctrineRoute
  options: { model: Category, type: object }
  param: { module: collection, action: showcollection }

并使用

url_for('@show_collection?collection='.$collection->getName());