I'm starting a new project - my first with Symfony - and I'm trying to figure out how to construct a route that incorporates information about an associated object. The documentation that I can find is light, to say the least, and I'm struggling. I'm using v1.4.1 w/ Propel (backwards compatibility with some existing stuff) and have:
A navigation menu (Menu
) that has_many
pages (Page
) through
a navigation item (NavItem
)
I realize that syntax doesn't really apply to Propel, but you get the idea, I hope. I'd like to access a page through a URI that includes it's menu and page slugs. For example, to display the page named Find an Audience on the Audiences menu, I'd like to use /audiences/find
. The route, then, for @page_show
would look something like /:menu_slug/:slug
.
The relevant snippet of the schema lays out like this:
Menu:
id: ...
name: ...
slug: ...
Page:
id: ...
name: ...
slug: ...
NavItem:
menu_id: ...
page_id: ...
display_order: ...
I may also be off on some of the routing specifics, but what I'm not sure how to do is configure my route in its entirety (including how to reference it in my layouts/templates using the link_to()
and url_for()
helpers.
Solutions or anything just to get me started in the right direction would be much appreciated.
Thanks.