문제

I have the following I have the following settings at 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 }

The link works correctly, however with one problem. The link is this:

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

So it's making /module/action/module/name_of_collection. What I needed was:

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

It would make a lot more sense even though it works as it is now. I already looked at jobeet and other routing tutorials, however I can't figure out what's wrong.

Thanks in advance!

EDIT:

Heres the url_for:

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

This is the result:

  .../collection/showcollection/collection/{collection Name}
도움이 되었습니까?

해결책

Try to change the route to:

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

and use

url_for('@show_collection?collection='.$collection->getName());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top