0

I have a defined route that displays a dynamic page:

page_show: url: /:domain_slug/:slug class: sfPropelRoute options: model: Page type: object method: doSelectByDomain param: { module: page, action: show } requirements: sf_method: [get] 

This works great, but now I want my homepage URI to route to a specific page. To do that, I assume that I have to pass the :domain_slug and :slug values of the page I want to display as the homepage. That's fine, but I can't seem to track down any documentation or example that shows me how to go about doing that.

Is it possible to specify specific variable values in a route? In this case, I want to pass :domain_slug => portal, :slug => dashboard (that syntax doesn't work, btw). Essentially, I want to create a homepage route that looks something like this:

homepage: url: / class: sfPropelRoute param: { module: page, action: show, array( :domain_slug => portal, :slug => dashboard ) } options: model: Page type: object method: doSelectByDomain 

But different enough that it, you know, works. :-) I suppose I could create a simple route to a different method, modify the request parameters manually and forward to the executeShow() method, but that's a hack I'd rather avoid if a more elegant solution is available.

Thanks.

3 Answers 3

3

You can define values in the param key of the route... for example:

homepage: url: / class: sfPropelRoute param: { module: page, action: show, domain_slug: portal, slug: dashboard} options: model: Page type: object method: doSelectByDomain 

At least thats how it works with a non propel/doctrine route. I assume it should be the same with any type of route in the framework.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I tried that too. When the workflow reaches my custom handler method (doSelectByDomain), no parameters are there. The array is completely empty.
0

I never found a way to do this that worked (or maybe I just couldn't manage to do it correctly). My solution was to create the route and pass it through a custom method that does the work to specify the appropriate page details:

homepage: url: / class: sfPropelRoute options: model: Page type: object method: doSelectHomepage param: { module: page, action: show ) } requirements: sf_method: [get] 

The doSelectHomepage() method does all of the work I was hoping I'd be able to do by hardcoding values in the route itself.

1 Comment

that's horrible. is this really the solution? symfony is such a stupid framework...i'm in the same boat and really don't want to do that... you're supposed to just be able to pass in param: { misc_arg: value } according to everything i'm reading, but it doesn't work. argh
0

Actually it did work, it was just the order in which the routes were defined. The first answer is correct. It may have worked for you if you added "homepage" rule BEFORE the "page_show" rule. So maybe Symfony isn't as stupid as I thought...No, no, it is. It's just not that bad.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.