Welcome Guest, Not a member yet? Register   Sign In
Extending a custom library
#1

[eluser]Tim Jukes[/eluser]
Hi - I'm familiar with how to extend a native library class, however I'm using a custom library (in this case, Simplepie) and I need to override one of the functions on occasion. I tried this but it doesn't appear to be working:

Code:
<?php
class Simplepiecustom extends SimplePie
{    
    function sort_items($a, $b)
    {
        return strcasecmp($a->get_title(), $b->get_title());
    }
}

?>

And I'm loading them as follows:
Code:
$this->load->library('simplepie');
$this->load->library('simplepiecustom');

Do I need to rename the new library MY_simplepie or something in the same way you do for the native libraries?

Thanks
Tim
#2

[eluser]Buso[/eluser]
I don't know why that isn't working, but unless you are going to use both classes, you should load only the second one. The parent class should be fetched with an include, or __autoload, so it doesn't get instantiated.
#3

[eluser]Tim Jukes[/eluser]
Thanks, Buso

I was being an idiot - trying to use
Code:
$this->simplepie->get_items()
instead of
Code:
$this->simplepiecustom->get_items()

Think I need a nap!




Theme © iAndrew 2016 - Forum software by © MyBB