Cannot extend pagination class? |
[eluser]fancms[/eluser]
Because there are several config settings for pagination that I would use over and over again it made sense (to me) to create a function where, when using it, I could simply plug in the 2 or 3 variables needed and all would be well. However, when I tried to create a library extending the Pagination class (which I assume is what I would need to do to extend said class), I keep getting a Fatal error that says the pagination class does not exist. I've tried several different methods, including loading the Pagination class prior to using my library, and still no go. I double-checked that the library I wrote was in the /application/libraries folder. I'm simply stumped. Here's the code I have for my library: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); The pagination function works fine by itself, so I'm totally confused here 8-/
[eluser]xwero[/eluser]
it's CI_Pagination, most libraries are prefixed with CI_
[eluser]esra[/eluser]
The subclass_prefix variable in config.php is the subclass prefix that CodeIgniter checks for in application/libraries. The default setting is MY_. If a file called MY_Pagination.php exists in application/libraries/ and the class name is MY_Pagination extended from CI_Pagination, it will be automatically loaded as an extension to the CI_Pagination class. You can change MY_ to anything you want. For example, you could change 'MY_' to 'C' and create a CPagination class. ---- EDIT: I have not tried this in a while, but you could. If a file called Pagination.php exists in application/libraries/, CI should load it as a complete replcement for sytem/libraries/pagination.php. The CI_ and MY_ solutions are used to work around PHP's lack of support for namespaces. If instead you wanted to add support or namespaces to CI, you might be able to do it using the namespaces library from the Claw framework's core (core.namespaces), or one of the solutions posted elsewhere on the web (e.g., phpclasses.org).
[eluser]fancms[/eluser]
I have tried both ways - with the MY_ and CI_ and without and I get the same message 8-/
[eluser]xwero[/eluser]
[quote author="fancms" date="1193595154"] Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); change it to Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
[eluser]fancms[/eluser]
Ahh, I see. Thanks, xwero; it's working perfectly now
[eluser]paulopmx[/eluser]
Ahem. :-) Why don't you try my function at http://ellislab.com/forums/viewthread/64287/ It does the same thing, but you are only given the values you need to construct your own custom paging style in the view files. So you are no longer stuck with just link style paging, and because its just a function you add to a plugin no more init configs. |
Welcome Guest, Not a member yet? Register Sign In |