Welcome Guest, Not a member yet? Register   Sign In
Problem extending library
#1

[eluser]Sumeet Kashyap[/eluser]
Hi folks!
There is a problem extending my library on server but i is working perfectly fine on local wamp. I am trying to extend the CI pagination library with my own library using the following code:

Code:
class my_pagination extends CI_Pagination {
    function __construct($params = array())
    {
        parent::__construct($params);
    }

    function initialize_js_function($jsFunction = array())
    {
          // Code here
    }
}

I have set the config param as:
Code:
$config['subclass_prefix'] = 'my_';

The server is running linux where i know the file system is case sensitive and so i have named the library as "my_pagination.php". I am loading the library as it should using
Code:
$this->load->library('pagination');
but it seems to having some problem and giving me the error:
Fatal error: Call to undefined method CI_Pagination::initialize_js_function()

Please help,
Thanks in advance :red:
#2

[eluser]InsiteFX[/eluser]
Should be this:
Code:
class MY_Pagination extends CI_Pagination {

If you look in your application/config/config.php file you will see the.
Code:
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries.  For more information please see the user guide:
|
| http://ellislab.com/codeigniter/user-guide/general/core_classes.html
| http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';

InsiteFX
#3

[eluser]Sumeet Kashyap[/eluser]
Thanks for the quick reply InsiteFX.

Actually i have tried that as well as it was 'MY_' by default but still the same problem. It is still giving the same error. On local wamp its running smoothly whatever the name of the class be. Is there any other way round loading the libraries explicitly and then using the extended functions? Or any other solution?
#4

[eluser]Sumeet Kashyap[/eluser]
Solved the problem.

I was extending the orignal pagniation class using:
Code:
class my_pagination extends CI_Pagination {

}
and the file name as "my_pagination.php"

But in linux system the name of file should be "my_Pagination.php".
Works fine now. :coolhmm:




Theme © iAndrew 2016 - Forum software by © MyBB