开发者

masked own parameter in Symfony routing

开发者 https://www.devze.com 2023-04-07 21:29 出处:网络
If i will make own link in symfony: http://www.mypage.com/phone/show/id/1 for: http://www.mypage.com/linksone

If i will make own link in symfony:

http://www.mypage.com/phone/show/id/1

for:

http://www.mypage.com/linksone

in routing:

linksone:
  url: /linksone
  param: { module: phone, action: show, id: 1 }

what if i use own parameter in URL?

how example:

http://www.mypage.com/phone/show?number=3

i dont have change this link for

http://www.mypage.com/phone/show/number/3

i must use: http://www.mypage.com/phone/show?number=3 - with /number/3 doesnt work.

is possible make routing with own parameter?

linksone:
  url: /linksone
  param: { module: phone, 开发者_如何学编程action: show, number: 3 }

doesnt work


This page in the "Practical Symfony" tutorial explains the routing in Symfony: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/05

You can introduce parameters in your URL like this:

linksone:
  url: /phone/show/:number
  param: { module: phone, action: show }

If you want to make the :number parameter optional, you can add the default value to the param option:

linksone:
  url: /phone/show/:number
  param: { module: phone, action: show, number: 1 }
0

精彩评论

暂无评论...
验证码 换一张
取 消