Strange Behaviour with Pagination Class |
[eluser]CARP[/eluser]
Hi I've configured the pagination class inside a controller, and was working fine. I've put all the pagination config variables in config/pagination.php, working fine. The problem cames now with some code I added for getting the corresponding results from the model, using per_page and offset stuff Code from controller: Code: if ( $this->dx_auth->is_logged_in()) { Before I got the error (after I added the call to the model, etc.), I had the following lines stored in the config/pagination.php Code: $config['per_page'] = '20'; Now I had to move those lines into the controller itself so I don't get error... Can any1 tell me why? I'd like to have these variables stored globally for all the controllers, inside the config/pagination.php Hope you've understood my problem Thanks a lot in advance,
[eluser]ecigraeme[/eluser]
You could try this Quote:$this->config->load('pagination');
[eluser]jcavard[/eluser]
as ecigraeme stated, if your configuration settings reside in an external file, you can access it this way: Code: $this->config->item('param_name'); Code: $this->config->load('filename'); doc: http://ellislab.com/codeigniter/user-gui...onfig.html
[eluser]jedd[/eluser]
[quote author="CARP" date="1249356853"] I'd like to have these variables stored globally for all the controllers, inside the config/pagination.php[/quote] You're right - this should work. Have you tried not using the initialise function, as the pagination manual page suggests you don't need it if you have the bits in the config/pagination.php file. I mean, for testing purposes only, as obviously you want to be able to have basic config stuff set in the config file, and then modify it with new bits in an initialise function whenever you want to. (I'd expect it'd simply do an array_merge() thing on the two config arrays.) Can you try that, though, out of curiosity? I've not used the pagination class before, so can't offer much beyond that suggestion. Oh, you could try making a syntax error in the config/pagination.php file - just in case.
[eluser]CARP[/eluser]
Hi guys Thanks for the replies Some things: 1- If i put a syntax error in config/pagination.php CI stops, so seems to work. 2- If i erase the line Code: $this->pagination->initialize($config); 3- I made it work using Code: $this->config->load('pagination'); so If I call ...app/index.php/clients/list/20 then 20 value is assigned to $xx All this because... 4- config['uri_segment'] isn't working or is not applied correctly. Tried assigning 3, 4, etc. values but none works Thanks again |
Welcome Guest, Not a member yet? Register Sign In |