Welcome Guest, Not a member yet? Register   Sign In
Going the other way [Forum integration]
#1

[eluser]Hyra[/eluser]
After a lot of reading up and browsing through posts of people trying to do the same i gave up.

Gave up on trying to integrate a prebuilt forum into my CodeIgniter app.

Instead .. I'm gonna see if i can do it the other way around and wrap the app around the forum :o

Here's how I went about it (tried with SMF for now):

1) Added an exception in the .htaccess to allow subdirectory "forum"
2) Installed the forum (SMF) from the www.domain.com/forum/ dir
3) On top of the core index.php file of the forum I added
Code:
define("IN_FORUM", TRUE);
$CI =& get_instance();
4) In the CI index file i changed the application folder to use:
Code:
if(defined("IN_FORUM")) {
    $system_folder = "../../system";
}
else {
    $system_folder = "../system";
}

I figured this would allow me to use $CI as the 'CodeIgniter this' and could call function from there. Close!

Thing is there's this default_controller, likely calling your home directory thus showing your homepage in front of it.

This was solved by adding to the index() controller:
Code:
if(defined("IN_FORUM")) {
    return;
}
to make sure it doesn't process the default controller.


Now .. I personally think I'm on to something with this. I can use all of the models and libraries within the forum now.

But there's a problem. I can't access my session variables!

I'm not too worried about hacking the login and logout function of the forum (synch them with the authentication of the site), but this can only work if i can access the session variables from the original codeigniter site.

Code:
<?
$CI =& get_instance();
print_r($CI); // Prints the same information as if it was on a normal page
echo $CI->session->userdata("SOME_VAR"); // Prints nothing, even though it's there (and yes, I'm sure)
print_r($CI->session); // Prints a lot (as expected).
?>

So .. close, yet so far.

Maybe i'm just missing something simple, or maybe there's a better way to go about it?

Suggestions are more than welcome! Smile




Theme © iAndrew 2016 - Forum software by © MyBB