Resetting a Library for reuse |
[eluser]kevinprince[/eluser]
I'm trying to use the RSSparser library with 3 rss feeds, each needs to be loaded up and put into a html page. The outputed values seems to be that which ever feed is called first. Any idea on if i can reset the library after each use? Code: $id = $this->uri->segment(3, 0);
[eluser]nmweb[/eluser]
The more elegant way to do this is just use instances of the object. In CI this would look like <php> $id = $this->uri->segment(3, 0); $archive = $this->Archive->get_archive($id); $template = $this->Template->get_template($archive['template']); $templatename = $template['filename']; $feed = "./assets/" . $id . "/master.xml"; $feedb = "./assets/" . $id . "/feedb.xml"; $feedc = "./assets/" . $id . "/feedc.xml"; $date = date('d-m-y'); $this->load->library('RSSParser', array('url' => $feed, 'life' => 0)); $data['master'] = $this->rssparser->getFeed(50); $data['feedb']=new RSSParser(array('url' => $feedb, 'life' => 0)); $data['feedb'] = $data['feedb']->getFeed(50); $data['feedc']=new RSSParser(array('url' => $feedc, 'life' => 0)); $data['feedc'] = $data['feedc']->getFeed(50); $this->load->view('templates/' . $templatename, $data); </php> Something like this
[eluser]kevinprince[/eluser]
Going to sound like th FNG but I just tried what you suggested and some variations and I get Code: Message: Undefined property: RSSParser::$RSSParser I assume this is because it isnt working as an instance. Suggestions welcome.
[eluser]xwero[/eluser]
Instead of loading the library several times, which doesn't work because it will be loaded only once, you should add a initialize method to your library like the File uploading library |
Welcome Guest, Not a member yet? Register Sign In |