CodeIgniter Forums
Codeigniter within existing site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Codeigniter within existing site (/showthread.php?tid=40768)



Codeigniter within existing site - El Forum - 04-18-2011

[eluser]suppster[/eluser]
Hi, I am trying to include a codeigniter comments section within certain pages of an existing site. I am using the following to include the codeigniter snippit:
Code:
echo $directoryLevelPrefix . "staff/codeigniter/index.php";
                            $_SERVER["REQUEST_URI"] = "comment/index2/".$page;
                            require_once($directoryLevelPrefix . "staff/codeigniter/index.php");

This works fine normally, but when I put the code in a function and call it I get the following error:
Quote:Fatal error: Call to a member function item() on a non-object in \codeigniter\system\core\Utf8.php on line 47

I guess codeigniter must be taking some details from the calling page which are out of scope in the calling function. Any ideas how to do this?


Codeigniter within existing site - El Forum - 04-18-2011

[eluser]toopay[/eluser]
Before you can use any of CI Instance/object, outside the CI Controller or model you must first declare
Code:
// This will be generates error if you put it outside CI Controller or CI Model scope
$this->load->library('some_ci_library');
// Declare CI instance first
$CI =& get_instance();
$CI->load->library('some_ci_library');