0

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

  • /controller/action/param/param/param/...
  • /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 ;>.

4

2 回答 2

0

如文档中所述(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 }

所以你的 routing.yml 可能看起来像:

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 }

但我不知道它是否有效......

请告诉我它是否有效!

弗洛里安。

于 2010-07-23T07:33:05.917 回答
0

嗯...我还没有使用 sf2.0 但类似的东西应该可以工作:

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

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

default:
  pattern:  /:controller/:action/*
  defaults: { _bundle: HelloBundle }
于 2010-05-31T00:30:41.943 回答