Suppose in my twig file I have following codes. Everything is working fine how to have different view if I click page number in Pagination tab. When I click page no2 it should have different output. Eg
<p> This is page no2</p>
My url http://localhost/project/web/app_dev.php/funfact/2 When I check current url using
{% if app.request.attributes.get('_route') == 'funfact/2' %}
</p> this is page no 2</p>
{%endif%}
it is not giving the above output.
How do I match current url with http://localhost/project/web/app_dev.php/funfact/2
Also in Phpstorm its giving me Alias 'Sensio\Bundle\FrameworkExtraBundle\Configuration\Route' is never used
In my twig view.html.twig
This is page 1
<div class="row">
<ul class="pagination pagination-lg">
<li><a href="#">«</a></li>
<li><a href="#">1</a></li>
<li><a href="{{ path('funfact', {'page': '2'}) }}"class="active">2</a></li>
<li><a href="{{ path('funfact', {'page': '3'}) }}"class="active">3</a></li>
<li><a href="#">»</a></li>
</ul>
</div>
routing.yml:
funfact:
path: /funfact/{page}
defaults: { _controller: HomeBundle:FunFact:funView, page: 1 }
Controller Class
class FunFactController extends Controller
{
/**
* @Route("/funfact/{page}"),defaults={"page" = 1})
*/
public function funViewAction($page)
{
return $this->render('HomeBundle::funfact.html.twig');
}
}