• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading a library from another

#1
[eluser]Unknown[/eluser]
A website of mine is using a third party library to fetch RSS feeds, and have successfully integrated into CI and load it into a controller.

The controller has a function to convert the RSS into a data structure which I can then further parse and use in a view. I've written several functions based on how I want to read the RSS, but these are rather long and detailed, and doing this for every controller that needs it isn't very manageable. I want to isolate those functions into its own library.

The library must still be able to load the third party RSS library and use its built in functions. Essentially I need something that is part wrapper for the RSS library and also further manipulate the feeds from there. Is there any way to do this? It sounds crazy to extend the wrapper library from the controller class, so there's probably some other approach I don't know of.

#2
[eluser]pickupman[/eluser]
Libraries are similar to controllers as they are classes. You should be able to the same code in the controller as in your RSS wrapper. Rather than using $this-> you will need to use:
Code:
$this->ci = & get_instance(); //CI super object

$this->ci->load->library('wrapper');


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.