CodeIgniter Forums
new to codeigniter - want try ci integrate with smf - 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: new to codeigniter - want try ci integrate with smf (/showthread.php?tid=37279)

Pages: 1 2


new to codeigniter - want try ci integrate with smf - El Forum - 01-04-2011

[eluser]javer[/eluser]
hi,

Im new to codeigniter (started maybe a few days ago) and have som really basic question about integration of CI and SMF (simple machine forum). I assume I should download smf (:-) ) and copy that files I dont know where it will be best. Could you help me please. I also found a phpbb library but I would rather use smf and also found some thread about smf integration but it didnt help me.

Thank you


new to codeigniter - want try ci integrate with smf - El Forum - 01-04-2011

[eluser]ecsyle31[/eluser]
Are you familiar with SMF at all? What is your goal?

It comes with a utility called SSI (http://docs.simplemachines.org/index.php?topic=400.0) that provides data from the SMF system. It is useful for pulling forum data out of the forums and into another area of your website. You can include this file in CodeIgniter to access its functionality. I do this with a CakePHP application and it works just fine.

If you are looking for further integration, such as being able to auto-post new threads, you will have to write that yourself.


new to codeigniter - want try ci integrate with smf - El Forum - 01-05-2011

[eluser]javer[/eluser]
Hi,

thank you for replay. My goal is to make a site and a forum. In my site I want to be able to login through SMF and then maybe do some things and then go into the forum. I read somewhere something about smf api. Should I use api or SSI. I see that ssi can do the job. Whats the difference between SSI and API ?
And my last question where should I copy smf forum, to the library folder, or application, whats the best for this?

thanks


new to codeigniter - want try ci integrate with smf - El Forum - 01-05-2011

[eluser]ecsyle31[/eluser]
The api is the SSI. You won't install SMF inside codeigniter at all, you will install it separately and just include SSI.php in CI app.

You could so something like this:

/path/to/webroot/forums/SMF_FILES_HERE
/path/to/webroot/system/
/path/to/webroot/index.php

then in your codeigniter app, include SSI.php - <?php require_once '/path/to/webroot/forums/SSI.php'; ?>

Now you have access to all the methods available in that file, as well as the $context array for the currently logged in user.


new to codeigniter - want try ci integrate with smf - El Forum - 01-05-2011

[eluser]javer[/eluser]
thank you for replay.

Got another problem. I cant use variable $context in my controller. Dont know why, however I can call a function from ssi, ssi_login(); and it works fine. But when I try to read $context echo $context it says:
Code:
Message: Undefined variable: context.

help please


new to codeigniter - want try ci integrate with smf - El Forum - 01-05-2011

[eluser]ecsyle31[/eluser]
Most likely this is because the codeigniter object doesn't know about the variable. Its a problem with scope. Where are you including SSI.php? You will need to assign $context to a local property:

Code:
var $context = array();

function __construct()
{
    require_once '/path/to/webroot/forums/SSI.php';
    $this->context = $context;
}

Now you can access the context area in your controllers methods by using $this->context;


new to codeigniter - want try ci integrate with smf - El Forum - 01-06-2011

[eluser]javer[/eluser]
Its not working, still same error

Code:
var $context = array();            
                
    function __construct()
    {
        parent::Controller();    
        
        require_once ('smf/SSI.php');
        $this->context = $context;    
    }

error:
Code:
Undefined variable: context

on this line $this->context = $context;


UPDATE:
Its working now. I have downloaded new smf 2 RC4 instead of 1.1.2. Maybe it was not because of old version of smf, but its working now. Smile Thank you very much rlindauer


new to codeigniter - want try ci integrate with smf - El Forum - 01-06-2011

[eluser]Daniel Moore[/eluser]
I used the following and received no error. This is using CI 2.0, however, so some minor differences. I don't really have a controller like this, I just created it as a demonstration. Ignore the var_dump() and echo statements. I don't actually use those in controllers, just a quick and dirty way to help you test.

Code:
<?php
class Context extends CI_Controller {

var $context = array();

  function __construct()
  {
    parent::__construct();
    require_once (FCPATH.'/smf20/SSI.php');
    $this->context = $context;
  }

  function index()
  {
    echo '<pre>';
    var_dump($this->context['user']);
    echo '</pre>';
  }
}

/* End of file context.php */
/* Location: application/controllers/context.php */

Notice the line:
Code:
require_once (FCPATH.'/smf20/SSI.php');

This is what you are missing I believe. If you will change your require_once statement to include the FCPATH constant, then it should be able to find SSI.php. I believe you just aren't locating it properly. I had the same error until I included the FCPATH.

I happen to use this all the time, and utilize extending my core controller so that it automatically sets this up in every controller I have. About 3/4 of my sites have the SMF board, so that's actually the auth system that I use. I also have MediaWiki, with full integration to SMF's auth system there as well. Although I prefer to set up separate permission tables from SMF for things that won't involve SMF directly. I just add another table to the SMF database that's being used. Works out great as an auth system if you're going to have the forum anyway.


new to codeigniter - want try ci integrate with smf - El Forum - 01-08-2011

[eluser]javer[/eluser]
Hi

Thank you all for help. Its working Smile. But I have another problem. I want to load avatars from smf users and display them. I found this http://www.simplemachines.org/community/index.php?topic=343752.0, but Im kind lost.

I've got in my view this piece of code
Code:
$member = loadMemberData($obj->id_member, false, 'normal');
foreach($members as $p)
{
loadMemberContext($p);
echo $memberContext[$p]['avatar']['image'];
}                                                }

But it ends with this error
Code:
Message: Undefined variable: memberContext

Dont know how to make memberContext available. Please Help


new to codeigniter - want try ci integrate with smf - El Forum - 01-08-2011

[eluser]javer[/eluser]
Got it working with this piece of code Wink

Code:
global $boardurl, $memberContext;
loadMemberData($obj->id_member);
loadMemberContext($obj->id_member);
$avatar = $memberContext[$obj->id_member]['avatar']['image'];

echo $avatar;

Sorry for bothering you