Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pagination class enhancement
  • Hello, It would be nice if we can write what we want in the prev and the next link with the create_links metod... for me i modify it like this :
     public static function create_links([b]$prev = null, $next = null[/b])
     {
      if (static::$total_pages == 1)
      {
       return '';
      }
      [b]if(!$prev)
      {
          $prev = '« Previous';
      }
      if(!$next)
      {
          $next = 'Next »';
      }[/b]
      $pagination = '';
    
      // Let's get the starting page number, this is determined using num_links
      $start = ((static::$current_page - static::$num_links) > 0) ? static::$current_page - (static::$num_links - 1) : 1;
    
      // Let's get the ending page number
      $end   = ((static::$current_page + static::$num_links) < static::$total_pages) ? static::$current_page + static::$num_links : static::$total_pages;
    
      $pagination .= ' '.static::prev_link([b]$prev[/b]).'  ';
    
      for($i = $start; $i <= $end; $i++)
      &#123;
       if (static::$current_page == $i)
       &#123;
        $pagination .= '<b>'.$i.'</b>';
       }
       else
       &#123;
        $url = ($i == 1) ? '' : '/'.$i;
        $pagination .= \Html::anchor(rtrim(static::$pagination_url, '/') . $url, $i);
       }
      }
    
      $pagination .= ' '.static::next_link([b]$next[/b]);
    
      return $pagination;
     }
    

    It would be nice to set this as attributes...
    If you have beter idea or other idea...?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!