Welcome Guest, Not a member yet? Register   Sign In
Help Extending SimplePie with CodeIgniter
#1

[eluser]CISCK[/eluser]
I'm extending SimplePie 1.2 with CodeIgniter to use a custom name space (as outlined in this NetTuts screencast). Everything is working as expected, but I can't figure out why I'm getting the following errors:

Errors:

1)
Severity: Warning
Message: Missing argument 1 for SimplePie_Item::SimplePie_Item(), called in /Applications/MAMP/htdocs/feeds/system/libraries/Loader.php on line 931 and defined
Filename: libraries/Simplepie.php
Line Number: 3114

2)
Severity: Notice
Message: Undefined variable: feed
Filename: libraries/Simplepie.php
Line Number: 3116

3 - 4)
I get the same errors again for the "data" variable.

Code:

Code:
// controllers/feeds.php

class Feeds extends Controller {

    function Feeds()
    {
        parent::Controller();    
    }

    function index()
    {
        $feed_url = 'http://myfeed.com/rss';
        $this->load->library('simplepie');
        $this->load->library('simplepie_item_extras');
        $this->simplepie->set_feed_url($feed_url);
        $this->simplepie->set_item_class('simplepie_item_extras');
        $this->simplepie->init();
        $this->simplepie->handle_content_type();

        $data['feed_items'] = $this->simplepie->get_items();
        $this->load->view('feed', $data);
    }

}

// libraries/Simplepie_item_extras.php

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

define('ITEM_NAMESPACE', 'http://custom-name-space/rss');

class Simplepie_item_extras extends SimplePie_Item {

    function get_name() {
        $data = $this->get_item_tags(ITEM_NAMESPACE, 'name');
        $name = $data[0]['data'];
        return $name;
    }

}

// views/feed.php

<?php foreach ($feed_items as $item): ?>

<p>Name: &lt;?= $item->get_name(); ?&gt;</p>

&lt;?php endforeach; ?&gt;

By the way, line 3116 in libraries/Simplepie.php is this function:

Code:
class SimplePie_Item
{
    var $feed;
    var $data = array();

function SimplePie_Item($feed, $data)
{
    $this->feed = $feed;
    $this->data = $data;
}

...

I could always suppress the errors because everything seems to be functioning, but it would be nice to understand why I'm getting them in the first place. Clearly, I am missing something. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB