title: How to display pagination on twig template
body: <p>This is how the pagination on the controller works </p>
  
  <pre><code> /**
       *@Route("/rating/{page}",name="testing")
       */
      public function pagesAction($page,Request $request)
      {
          // retrieve GET variables
          $pageNumber = $request-&gt;query-&gt;get('pageNumber');
          $pageSize = $request-&gt;query-&gt;get('pageSize');
  
                  $em = $this-&gt;getDoctrine()-&gt;getManager();
                  $qb = $em-&gt;createQueryBuilder();
  
                  $results = $qb-&gt;add('select', 'p')
                      -&gt;add('from', 'GabrielUploadBundle:Post p')
                      -&gt;add('where', 'p.upvotes &gt; 100')
                      -&gt;add('orderBy', 'p.createdAt ASC')
                      -&gt;setMaxResults($pageSize)
                      -&gt;setFirstResult($pageSize * ($pageNumber - 1))
                      -&gt;getQuery();
  
  
                  return $this-&gt;render('GabrielLayoutBundle:Worldpage:content_loop.html.twig',array('posts'=&gt;$results-&gt;getResult())); 
      }
  </code></pre>
  
  <p>now I only have to pass the pageNumber and pageSize for the URL (it works so far)</p>
  
  <blockquote>
    <p>/rating/front?pageNumber=1&amp;pageSize=3</p>
  </blockquote>
  
  <p>All I need to know is how to display the results like this 
  <img src="https://i.stack.imgur.com/FKyxG.png" alt="pagination"></p>
  
  <p>I've been struggling with this step since I don't know how to calculate the number of results and how to get the "next " and previous buttons to work</p>