Reputation: 314
I'm currently trying to uses dashes as segment separators in URL with Symfony 1.4.18, and I have some troubles to make it work.
Here is my route:
franchise:
url: /number-:page-:slug
param: { module: store, action: franchise, page: 1 }
options: { suffix: .html, segment_separators: [ /,- ] }
requirements:
page: \d+
As you can see, the pattern is very simple I define a constant "number" followed by a dash and a variable :page which is only a number. It is followed by a dash and a slug (the slug can contains alphanumeric values and dashes too).
The URL is correctly generated by the method url_for but when I try to access it, I have the usual error:
Empty module and/or action after parsing the URL...
I tried to replace the dash between :page and :slug by the plus sign (and adding it to the segment_separators) but it did not work neither.
I don't know what to do anymore? Does anyone already had this kind of trouble?
Upvotes: 2
Views: 1090
Reputation: 909
I tested that case more and more
You can't use more than one separator except /
Example
worked "/test-:test" -> one separator not worked "/test-:test-:test" more than one worked "/test/:test/:test" more than one but "/"
hope this information helpful Thanks..
Upvotes: 1
Reputation: 22756
The problem is your slug
has some dashes, so Symfony can't determine where is the separator between page
and slug
.
If you add a requirement to slug
, to explicitly tells Symfony that slug can contain dashes, it will works.
franchise:
url: /number-:page-:slug
param: { module: store, action: franchise, page: 1 }
options: { suffix: .html, segment_separators: [ /,- ] }
requirements:
page: \d+
slug: "[a-zA-Z0-9\-]+"
Upvotes: 1