Symfony route url (variable joined to a literal)
-
19-09-2019 - |
Question
I'd like to generate an URL like this one:
/MyCategory/MySubCategory/page2.html
I have tried to do it this way:
my_route:
url: /:variable1/:variable2/literal:variable3.html
But Symfony outputs this:
/MyCategory/MySubCategory/page:variable3.html
I'm using Symfony 1.4.1
How could I solve this?
Solution
Try:
my_route:
url: /:variable1/:variable2/:variable3
param: { module: mymodule, action: myaction }
in SF_APP/config/factories.yml:
prod:
routing:
param:
suffix: .html
Usage:
<?php echo url_for('my_route', array('variable1'=>'news', 'variable2'=>'sports', 'variable3'=>'page2'));?>
So it should produce:
/news/sports/page2.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow