Pagination config file not loading [Solved] |
[eluser]Adrian Walls[/eluser]
Hi, I have sucessfully added pagination to my application and I wanted to start to use css to style the pagination links. As this will be used in more than one place I want to put pagination configuration options into a config file so its available application wide. I have created my config/pagination.php file which looks like: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); and my controller looks like (NOTE: I am using Smarty for my view): Code: //Load models However when I use this as above the pagination links are not being created. The Pagination user manual page says that if you are using a config file then you do NOT need to initialize this using Code: $this->pagination->initialize($config); as its automatically loaded for you. However my pagination links do not appear at all if I don't include this initialize in my controller. Any ideas? All help greatly appriciated.
[eluser]Vi.[/eluser]
Try to track your mysql result. $query_rows may be smaller than $limit or equal to NULL. Code: echo $this->db->last_query(); // after mysql_query || db->get() Code: print_r($config); // after pagination config
[eluser]Adrian Walls[/eluser]
Quote:SELECT * FROM (`stock`) WHERE `deleted` = 0 ORDER BY `make` asc, `model` asc LIMIT 2, 1 Quote:Array ( [base_url] => http://localhost/dev/cleonard/index.php/...ist_stock/ [total_rows] => 5 [per_page] => 1 ) Also just an observation a colleague has tried this in one of his projects using CI v1.7.0 and it works as expected. I am using CI 1.7.2.
[eluser]Vi.[/eluser]
Your CSS code is working after including "$this->pagination->initialize($config);" ? Try to add this code to load pagination config file. As I see, config/pagination.php isn't included. Code: $this->load->config('pagination')
[eluser]Adrian Walls[/eluser]
To make sure there are no css issues I have striped my config/pagination.php to just: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); However its still not picking this up. The documentation also says that this is loaded automatically however I cannot see from the code how this actually happens. As I mentioned this is working OK for a colleague using 1.7.0 however he must use the line: Code: $this->pagination->initialize($config); even though the user guide says you do not need to use the initialize function if you are using the config file. I am not sure if this is directly related to my issue but on the surface it would appear in having to call the initialize function there is a error in the user manual or a bug in CI.
[eluser]Vi.[/eluser]
I figure it out now. This feature didn't explained well in User Guide. You must write your pagination config into config/pagination.php Example; Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Controllers; Code: //Load models It worked in my project (1.7.2).
[eluser]Adrian Walls[/eluser]
Found out what the problem was. My own stupid fault. I had expanded the Pagination library with MY_Pagination as I wanted to investigate setting up pagination links with "1-10, 11-20, 21-30 etc" style links. I quickly decided against this. However I forgot to remove MY_Pagination.php. This was causing the pagination config file not to get loaded. Anyway all working as expected. Thanks for your time and efforts Vi. and anyone else for looking into this. Sorry for wasting your time.
|
Welcome Guest, Not a member yet? Register Sign In |