symfony - Symfony2, how to pass a parameter off route -


id know how pass parameter off route

route:

frontend_agences_list:     path:     /agences/{page}     defaults: { _controller: projectfrontendbundle:frontend:listagences, page: 1 } 

is ?

twig:

<a href="{{ path('frontend_agences_list') }}?mode=list"> <a href="{{ path('frontend_agences_list') }}?mode=grid"> <a href="{{ path('frontend_agences_list') }}?mode=block"> 

in fact, i'd display results in 3 modes, list , grid , block. in controller test ,if mode=list render "list-view.html.twig", elseif mode=grid render "grid-view.html.twig" ....

is way or there way ?

twig:

<a href="{{ path('frontend_agences_list', {'mode': 'list'}) }}">list mode</a> <a href="{{ path('frontend_agences_list', {'mode': 'grid'}) }}">grid mode</a> <a href="{{ path('frontend_agences_list', {'mode': 'block'}) }}">block mode</a> 

your controller:

public function listagencesaction() {     $mode = $this->get('request')->get('mode');     if($mode == 'list') {         ...     } } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -