views:

62

answers:

2

Hi! How can I set up routing in symfony to be like that(if one rule won't work, next should be grabbed):

  1. /controller/action/param/param/param/...
  2. /admin/controller/action/param/param/param/... ("admin" is constant here - name of the bundle)

I tried that:

    homepage:
      pattern:  /
      defaults: { _bundle: HelloBundle, _controller: Hello, _action: index }
    default:
      pattern: /:controller/:action/*
      defaults: { _bundle: HelloBundle }
But it doesn't work, even for the first rule. Sorry for my English, and thanks for any future help ;>.

A: 

Hmmm... I didn't use sf2.0 yet but something like that should works:

homepage:
  pattern:  /
  defaults: { ... }

admin_default:
  pattern:  /admin/:controller/:action/*
  defaults: { _bundle: AdminBundle }

default:
  pattern:  /:controller/:action/*
  defaults: { _bundle: HelloBundle }
Crozin
A: 

Hi,

as read in the doc ( http://symfony-reloaded.org/quick-tour/part-3 ):

# src/Application/HelloBundle/Resources/config/routing.yml
hello:
    pattern:  /hello/:name
    defaults: { _controller: HelloBundle:Hello:index, _format: xml }

So your routing.yml could look like:

homepage:
  pattern:  /
  defaults: { _controller: HelloBundle:Hello:index }
default:
  pattern: /:_controller/*
  defaults: { _controller: HelloBundle:Hello:myaction }
default_admin:
  pattern: /admin/:_controller/*
  defaults: { _controller: HelloBundle:Hello:myAction }

But I don't know if it works....

Please inform me if it works !

Florian.

Florian
As a help, you can look at here: http://github.com/knplabs/symfony2bundles/blob/master/src/Application/S2bBundle/Resources/config/routing.ymlYou will find some very good examples here: http://symfony2bundles.org/
Florian