David Apshid
David Apshid

Reputation: 311

Routing in Symfony

I have two links:

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

and:

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

I would like makes links for this

http://www.mypage.com/linksone

and

http://www.mypage.com/linkstwo

Is it possible to do that with Symfony routing system?

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

linkstwo:
  url: /linkstwo
  param: { module: phone, action: show}

Where I can add ID?

Upvotes: 0

Views: 219

Answers (2)

codeguy
codeguy

Reputation: 700

If you want to do this in Symfony 2+ you need to do the following routing, hopefully someone will find this useful. This is just an example and not using your names/routes.

home_route:
   path: /home
   defaults: { _controller: DemoCoreBundle:StaticPageController:home }

about_route:
   path: /about
   defaults: { _controller: DemoCoreBundle:StaticPageController:about }

team_route:
   path: /team/{member_id}
   defaults: { _controller: DemoCoreBundle:StaticPageController:team, member_id:null }
   requirements:
       member_id: \d+

Upvotes: 0

Kaivosukeltaja
Kaivosukeltaja

Reputation: 15735

I believe this should do it:

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

linkstwo:
  url: /linkstwo
  param: { module: phone, action: show, id: 2}

Upvotes: 2

Related Questions