Access codeigniter super object from external files |
[eluser]helmutbjorg[/eluser]
Hi Guys, I think I am getting closer to a simple way to access the CI super object from an external script. Sometimes you need the methods inside third party scripts (like forums, wikis, fckeditor filemanager, etc) to authenticate, etc. My idea is to simply include the main index.php inside phps output buffering somehow... For example we have a script external.php Code: ob_start(); I have hit a problem which I think there must be a solution to. It works perfectly if I do not echo anything to the screen. The only time it doesn't work is when I have Output Compression set to true in the config.php and I echo something. If I don't output anything it works great with compression on. I would like this to work with this setting true or false. The error I get is the standard browser error 'Content Encoding Error'. Anyone have any ideas? I know that other people have had other ideas to fix this general problem (such as Dip Into CI http://codeigniter.com/wiki/dip_into_CI/) etc but I think if this works it is a VERY simple solution. Cheers Steve
[eluser]helmutbjorg[/eluser]
An update... At this stage this system works with the following conditions... a) Must have Output Compression set to false b) Must not be using CodeIgniter with GET vars enabled (by default they are off) How to use 1. Create file called external.php (or whatever) with the following code Code: <?php Code: require('external.php');
[eluser]whobutsb[/eluser]
Thank you for posting this method on how to access the CI Super Object. I'm having a slight problem with using it though. What I'm trying to do is be able to access CI libraries and resources in Wordpress. My setup is as follows: Code: CI Root From what I can understand from your tutorial I have the following settings set in my CI config: Quote:$config['enable_query_strings'] = TRUE; And in the header of my Wordpress Theme I have this added: Code: <?php Whenever I load the blog I get the error message: Code: Fatal error: Call to undefined function get_instance() in C:\wamp\www\Green\wp-content\themes\default\header.php on line 3 Am I missing something from your instructions?
[eluser]123wesweat[/eluser]
and did you get this to work i am also trying to <?php $this->load->view('from_ci_view');?> in a WP theme
[eluser]123wesweat[/eluser]
[quote author="helmutbjorg" date="1231406839"]An update... 2. In your external scripts you use it like so... Code: require('external.php'); could you give me an example how you use the CI load views in WP? regards
[eluser]Phil Sturgeon[/eluser]
Code: <?php $this->load->view(‘from_ci_view’);?> $this refers to the current object. You should be using: Code: $ci =& get_instance();
[eluser]123wesweat[/eluser]
ha that´s looks promising But i get an error on the $CI =& get_instance(); Code: Fatal error: Call to undefined function get_instance() in /var/www/vhosts/domain.com/blog/wp-content/themes/test/header.php on line 13 in header.php i have Code: require_once('../external.php'); in external.php i have Code: ¨// Remove the query string btw i have added Code: require_once './blog/wp-load.php';//WP so i can use WP functions in CI views. ps http://wiki.title.cz/user_guide/general/...aries.html |
Welcome Guest, Not a member yet? Register Sign In |