We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Codeigniter libraries and overriding functions

Development and Programming

Tim Jukes's avatar
Tim Jukes
13 posts
15 years ago
Tim Jukes's avatar Tim Jukes

Hi - I’m writing a plugin for parsing RSS feeds. I wanted to take the opportunity to try to link it in with Codeigniter.

So… I grabbed Eliot Haughin’s great CI wrapper for SimplePie, and dropped it into the System/Libraries folder.

I’ve been able to call it and do everything I normally would with CI like this:

$this->EE->load->library('simplepie');

I just wondered if anyone could see anything wrong with this approach? Should I be putting the library in the plugin folder instead?

I’ve also run into an issue trying to override one of the functions. I tried loading

$this->EE->load->library('simplepiecustom');

straight after loading simplepie. The custom class is just set up to override one function, but I can’t seem to get it to work - the class loads in without an error, but the original sort function still gets called.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

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

?>

Anyone have any advice?!

Thanks Tim

       
Tim Jukes's avatar
Tim Jukes
13 posts
15 years ago
Tim Jukes's avatar Tim Jukes

Well, I was being silly, I was loading both libraries, but calling the original, rather than the custom one, e.g.

$this->EE->simplepie->get_items();

rather than

$this->EE->simplepiecustom->get_items();
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.