title: PHP pagination set pages on view custom PHP MVC
body: <p>Here is my method im getting all posts correctly and i can switch over them from url exemple simply  <code>posts/1 or posts/2</code> etc.. 
  How can i set set a paginator on my view in this case ?</p>
  
  <p>Here is the controller :</p>
  
  <pre><code>namespace fordev\app\controllers;
  
  use fordev\app\core\Controller;
  
  class Home extends Controller
  {
      public function manage($page = NULL)
      {
          \Session::checkNotIsset('logged','/pfe/login');
          $model = $this-&gt;model('home')-&gt;getAllPosts($page);
          $this-&gt;view()-&gt;renderWithAdditionalHeaderAndFooter('home',['Manage'], 'Home', [$model]);
      }
  }
  </code></pre>
  
  <p>Here is the Model:</p>
  
  <pre><code> namespace fordev\app\models;
   use fordev\app\core\Model;
  
  
  class Home extends Model 
  {
      /**
       * Get All posts method
       * @param $page = current page
       */
      public function getAllPosts($page)
      {
          $con  = $this-&gt;getInstance();
  
          $page  = (isset($page) &amp;&amp; $page &lt; 100000)? (int) $page : 1;
          $perPage = 5;
          $start = $perPage * ($page - 1);
          $total = \Database::countRows($con, '*','annonce');
          $totalPages = ceil($total / $perPage);
  
          $next = $page+1;
          $prev = $page-1;
  
          $sql  = "SELECT * FROM annonce INNER JOIN users ON users.ID =  annonce.a_publisher ORDER BY a_id DESC LIMIT $start, $perPage";
          $stmt = $con-&gt;prepare($sql);
          $stmt-&gt;execute();
  
          return ($stmt-&gt;rowCount() &gt; 0) ? $stmt-&gt;fetchAll() : false;
      }
  
  
  }
  </code></pre>
  
  <p>And here is the view :</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div class="col-md-12"&gt;
          &lt;div class="blog-header"&gt;
              &lt;h1 class="blog-title"&gt;Les Annonce De Kisoun&lt;/h1&gt;
              &lt;p class="lead blog-description"&gt;Tous les annonces de village Kissoun se trouve ICI !.&lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="col-md-8"&gt;
          &lt;?php if(is_array($modelData[0])): // if there is data in the database ?&gt;
      &lt;?php foreach ($modelData[0] as $value) {  // foreach loop ?&gt;
  
          &lt;div class="panel panel-default"&gt;
        &lt;div class="panel-heading"&gt;
          &lt;h3&gt;&lt;?=$value-&gt;a_title ?&gt;&lt;/h3&gt;
        &lt;/div&gt;
  
              &lt;div class="panel-body annonce"&gt;
  
                  &lt;div class="annonce-image pull-left"&gt;
                      &lt;img src="&lt;?=Rooter::get('UP_IMG').$value-&gt;a_image ?&gt;" alt=""&gt;
                  &lt;/div&gt;
  
          &lt;p class="pull-right"&gt;&lt;?=$value-&gt;a_content ?&gt;&lt;/p&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;
          &lt;hr&gt;
            &lt;a class="btn btn-danger pull-right"&gt;Details&lt;/a&gt;
            &lt;span class="label pull-left"&gt;&lt;?= \Helper::elapsedTime($value-&gt;a_time) ?&gt; by &lt;?=$value-&gt;name ?&gt;&lt;/span&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
  
     &lt;?php   } // end of foreach loop ?&gt;
  
    &lt;?php endif; ?&gt;
    &lt;?php if($modelData[0] === false): ?&gt;
        &lt;div class="alert alert-danger"&gt;
          &lt;button type="button" class="close" data-dismiss="alert" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
          &lt;strong&gt;Error&lt;/strong&gt; Pas D'annonce encore ...
        &lt;/div&gt;
    &lt;?php endif; ?&gt;
      &lt;/div&gt;
  
  
  &lt;/div&gt;
  </code></pre>