Symfony percorso URL (variabile unito ad un letterale)
-
19-09-2019 - |
Domanda
mi piacerebbe per generare un URL simile a questo:
/MyCategory/MySubCategory/page2.html
Ho cercato di fare in questo modo:
my_route:
url: /:variable1/:variable2/literal:variable3.html
Ma Symfony Risulterà:
/MyCategory/MySubCategory/page:variable3.html
sto usando Symfony 1.4.1
Come posso risolvere questo problema?
Soluzione
Prova:
my_route:
url: /:variable1/:variable2/:variable3
param: { module: mymodule, action: myaction }
in SF_APP / config / factories.yml:
prod:
routing:
param:
suffix: .html
Utilizzo:
<?php echo url_for('my_route', array('variable1'=>'news', 'variable2'=>'sports', 'variable3'=>'page2'));?>
Così dovrebbe produrre:
/news/sports/page2.html
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow