Welcome Guest, Not a member yet? Register   Sign In
pagination not reading config file
#1

[eluser]boony[/eluser]
Hi All,

I'm doing a new project in CI2 and have encountered what looks like a problem with the pagination class.

I've set up some pagination options as below:
Code:
$config['uri_segment'] = 5;
        $config['first_tag_open'] = "<span style='color: green'>";
        $config['first_tag_close'] = '</span>';
        $config['first_link'] = "First";
        $config['last_link'] = "Last  Page";
        $config['num_tag_open'] = "<span style='color: red; padding: 4px'>";
        $config['num_tag_close'] = "</span>";
        $config['full_tag_close'] = "</div'>";
        $config['anchor_class'] = "pager";
        $this->pagination->initialize($config);

But when I run the program the pagination options - like last link or anchor_class are not working. Even the default First Last do not show up all I get is

1 2 >

When I run just the
Code:
$config['anchor_class']
option the pagination is built but the links do not work. I've even tried setting up the pagination config file but that is not being read.

I'm not sure if there is a bug with CI2 and pagination or I'm doing something wrong.

Regards
Boony
#2

[eluser]lontong balap[/eluser]
haven't you check your :
Code:
$config['base_url']
$config['per_page']
#3

[eluser]VanTheMan[/eluser]
I have the same problem with my pagination . My code is
Code:
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/site/index';
$config['total_rows'] = $this->db->count_all_results('thesis');
$config['per_page'] = '3';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['first_link'] = "First";
$config['first_tag_open'] = '<div>';
$config['first_tag_close'] = '</div>';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<div>';
$config['last_tag_close'] = '</div>';
$this->pagination->initialize($config);
And in my view,
Code:
echo $this->pagination->create_links();
It doesn't display the First and Last ???
Please help me!!
#4

[eluser]boony[/eluser]
[quote author="anodyne sea" date="1304663302"]haven't you check your :
Code:
$config['base_url']
$config['per_page']
[/quote]

Hi,
Yes, thats ok, I didn't paste those in but all the required config has been set. I've changed just about everything and switched all things on and off but it doesn't work....
#5

[eluser]lontong balap[/eluser]
hmm.. for comparison, here's my pagination for my last project and it works..
Code:
$this->load->library('pagination');
$config['base_url']=base_url().'index.php/articles/listing';
$config['total_rows']=$this->frontend->get_count_articles($where);
$config['uri_segment']=3;
$config['per_page']=20;
$config['num_links']=3;
$config['cur_page']=0;
$config['next_link']="next";
$config['prev_link']="prev";
$config['last_link']="last";
$config['first_link']="first";
$config['first_tag_open']="<div class='arrow_paging'>";
$config['first_tag_close']="</div>";
$config['last_tag_open']="<div class=arrow_paging>";
$config['last_tag_close']="</div>";
$config['next_tag_open']="<div class='arrow_paging'>";
$config['next_tag_close']="</div>";    
$config['prev_tag_open']="<div class='arrow_paging'>";
$config['prev_tag_close']="</div>";    
$config['num_tag_open']="<div class='num_paging'>";
$config['num_tag_close']="</div>";        
$config['cur_tag_open']="<div class='cur_paging'>";
$config['cur_tag_close']="</div>";
$this->pagination->initialize($config);
where 'total_row' i get from model 'frontend'..
I hope it will helps
#6

[eluser]boony[/eluser]
Hmmm, well I copied and pasted your config items, using my specs where necessary as in
Quote: $this->load->library('pagination');
//$config = array();
$config['base_url'] = site_url("home/display/$sort_by/$sort_order");
$config['total_rows'] = $data['num_results'];
$config['per_page'] = $limit;
$config['uri_segment'] = 5;
$config['cur_page']=0;
$config['next_link']="next";
$config['prev_link']="prev";
$config['last_link']="last";
$config['first_link']="first";
$config['first_tag_open']="<div class='pager'>";
$config['first_tag_close']="</div>";
$config['last_tag_open']="<div class='pager'>";
$config['last_tag_close']="</div>";
$config['next_tag_open']="<div class='pager'>";
$config['next_tag_close']="</div>";
$config['prev_tag_open']="<div class='pager'>";
$config['prev_tag_close']="</div>";
$config['num_tag_open']="<div class='pager'>";
$config['num_tag_close']="</div>";
$config['cur_tag_open']="<div class='pager'>";
$config['cur_tag_close']="</div>";
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();

and now I get no pagination at all. Another page using my original config shows pagination but not with 'first' 'last' etc as per original post.

One question, are you using this pagination with CI2??

I'm convinced there must be a bug here somewhere.
#7

[eluser]lontong balap[/eluser]
yup, i'm using this with CI2
i think you better clear all config except ‘base_url’, ‘total_rows’ and 'uri_segment'
see whether your pagination works properly with basic Pagination library config..
#8

[eluser]boony[/eluser]
[quote author="anodyne sea" date="1304673095"]yup, i'm using this with CI2
i think you better clear all config except ‘base_url’, ‘total_rows’ and 'uri_segment'
see whether your pagination works properly with basic Pagination library config..[/quote]

Already done all that. That's the problem, the pagination works with the basic config, but does not show the default 'first' and 'last' page links and refuses to accept my custom config items...I've even checked the pagination class itself and verified that the default options are set in the class itself.

I'm going to get a fresh ci2 install and see if the problem still persists.
#9

[eluser]boony[/eluser]
Hmmm, hold yer horses everyone. Seems that somehow my pagination class was corrupted (well that's my excuse and I'm sticking to it Smile )

I reloaded the system folder and now things seem to be working. I've still got a problem with
Code:
$config['anchor_class']
stopping the pagination from working but I think that must be a problem my side so will hunt it down and kill it (not unlike what they did to OBL)

boony
#10

[eluser]InsiteFX[/eluser]
For the anchor_class you need to assign it a css class form your css file!
Code:
// css file.
.pager {
    background-color: #c0c0c0;
}

// anchor_class
$config['anchor_class'] = 'pager';

Not sure if your doing that, but that is how it is done.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB