Welcome Guest, Not a member yet? Register   Sign In
Pagination config file and ontime changes
#4

[eluser]Unknown[/eluser]
OK this is easy, but confusing because CI states that:
Quote:You will NOT need to use the $this->pagination->initialize function if you save your preferences in a config file.

With that I tried something similar to the above work until I realized I was paying attention to the "NOT" and not the "need". Need should have been all caps because it is the key to the puzzle.

1. Set your custom settings that you want to use site wide in a file named:
Quote:pagination.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    $config['num_links'] = 3;
    $config['next_link'] = '›';
    $config['prev_link'] = '‹';
    $config['first_link'] = '«';
    $config['last_link'] = '»';
    
    $config['first_tag_open'] = '<span class="large_txt">';
    $config['first_tag_close'] = '</span>';
    $config['last_tag_open'] = '<span class="large_txt">';
    $config['last_tag_close'] = '</span>';
    
    $config['next_tag_open'] = '<span class="large_txt">';
    $config['next_tag_close'] = '</span>';
    $config['prev_tag_open'] = '<span class="large_txt">';
    $config['prev_tag_close'] = '</span>';

2. In the controller do as normal:
Code:
function index(){
    $this->load->library('pagination');

    $config['base_url'] = 'http://example.com/index.php/test/page/';
    $config['total_rows'] = '200';
    $config['per_page'] = '20';

    $this->pagination->initialize($config);

That is it, when you use a custom pagination.php file AND set additional config items in your controller then still use
Code:
$this->pagination->initialize($config);
CI will apply the config items in the following order:
(this assumes you used a pagination.php file in application->config folder but still want to set a few settings per controller)
Quote:
1. base_settings for pagination.
Quote:2. Pagination.php (this will win over same name items in default config)
Quote:3. Controller level.(This will win over default and any pagination.php config files, this is also dependent on you using
Code:
$this->pagination->initialize($config);
in your controller. If you don't any config items set in the controller will be ignored)

So you see that you were simply over thinking it that is all. Have a good day.


Messages In This Thread
Pagination config file and ontime changes - by El Forum - 07-20-2010, 01:29 PM
Pagination config file and ontime changes - by El Forum - 07-20-2010, 06:37 PM
Pagination config file and ontime changes - by El Forum - 07-20-2010, 06:45 PM
Pagination config file and ontime changes - by El Forum - 07-24-2010, 11:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB