• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using initialize() in pagination with an external configuration

Hi, in the pagination docs it says

Quote:You will NOT need to use $this->pagination->initialize() if you save your preferences in a config file.

I have made this file and have a bunch of configurations there, but if I leave the initialize part out of my controller, the pagination links don't show at all. It's not a big deal because it works when I add it, but I was curious know what the docs meant by this.

Here is my code


PHP Code:
public function read($pagination_offset 0)
     $pagination_config['base_url'] = base_url().'/language/read/'
     $pagination_config['per_page'] = 20

     $this->data['languages'] = $this->language_model->get_languages($pagination_config['per_page'], $pagination_offset); 
     $total_query_rows $this->db->query('SELECT id FROM languages')->num_rows(); 

     $pagination_config['total_rows'] = $total_query_rows;

     $this->data['pagination'] = $this->pagination->create_links(); 


PHP Code:
   public function get_languages($limit$pagination_offset)
     $query $this->db->query("
      languages.id AS id,
       languages.title AS language,
      COUNT(courses.id) AS number_of_courses
     FROM languages
     LEFT JOIN courses
     ON languages.id = courses.language_id
     GROUP BY languages.title
$limit OFFSET $pagination_offset
     $languages $query->result();
     return $languages;

PHP Code:
('BASEPATH') OR exit('No direct script access allowed');

   $config['full_tag_open'] = '<ul class="w3-pagination w3-border w3-light-grey">';
   $config['full_tag_close'] = '</ul>';

   $config['first_link'] = 'First'// might require more than 5 pages by default to show up
   $config['first_tag_open'] = '<li>';
   $config['first_tag_close'] = '</li>';
   // $config['first_url'] = ''; // An alternative URL to use for the “first page” link.

   $config['last_link'] = 'Last';
   $config['last_tag_open'] = '<li>';
   $config['last_tag_close'] = '</li>';

   $config['next_link'] = '&raquo;';
   $config['next_tag_open'] = '<li>';
   $config['next_tag_close'] = '</li>';

   $config['prev_link'] = '&laquo;';
   $config['prev_tag_open'] = '<li>';
   $config['prev_tag_close'] = '</li>';

   $config['cur_tag_open'] = '<li><b><a class="w3-green" href="#">';
   $config['cur_tag_close'] = '</a></b></li>';

   $config['num_tag_open'] = '<li>';
   $config['num_tag_close'] = '</li>'


PHP Code:
   <?php if (!empty($pagination)): ?>
     <div class="w3-container">
       <div class="w3-card-2 w3-padding w3-light-grey">
         <?php echo $pagination?>
   <?php endif; ?>

Thanks Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.