Including a codeigniter snippit in another site

2019-06-12 20:26发布

问题:

I would like to include a CI comment form in selected pages in an existing non CI site. I’ve tried using

$_SERVER["REQUEST_URI"] = "cms/2";

//Set GET action,method params etc

require_once "path/to/index.php";

When I include the above code in a file outside the codeigniter root I get

Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php

Any ideas? Thanks

回答1:

It was a relative path problem. The included file obviously uses the path of the calling function. I just needed to include

$application_folder = dirname(__FILE__)."/application";
$system_path = dirname(__FILE__)."/system"; 

in index.php