Question

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}
Was it helpful?

Solution

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());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top