i'm running issues trying guess how handle urls parameters on symfony+twig.
i have route:
<route id="artist.front" path="/artist/{kw}/"> <default key="_controller">app\web\controllers\front::homepage</default> </route> and code on twig template:
{% autoescape false %} <a href="{{ path('artist.front',{'kw':a.urlkeyword|url_encode} )}}">{{ a.name }}</a> {% endautoescape %} urlkeyword parameter passed (i.e. not url encoded previously) both on entity constructor , on getter (geturlkeyword).
however, when rendering template html code:
<a href="/index.php/artist/ac%252fdc/">ac/dc</a> (if remove url_encode template twig throws error calling path()).
the target controller has code:
public function artistpage($kw) { $decoded = urldecode($kw); $this->log->info("kw: {$kw}"); $this->log->info("decoded: {$decoded}"); } and echoes:
kw: ac%2fdc decoded: ac/dc so think kw read correctly controller, understand url should encoded ac%2fdc instead on final html code on first place: urlencoded string encoded twice.
is ac%2fdc correct encoding, or necessary use double encoding (ac%252fdc) in symfony? and, if possible use first (correct) url encoding, doing wrong?
try:
<route id="artist.front" path="/artist/{kw}/"> <default key="_controller">app\web\controllers\front::homepage</default> <requirement key="kw">.+</requirement> </route> and remove url encoding/decoding.
Comments
Post a Comment