views:

45

answers:

1

hi guys,

SORRY FOR THE LONG POST. I JUST WANT TO BE CLEAR!! :cheese:

I am using the stated template library in my ci setup and everything works great except for when i use Mr. Haughin's facebook_connect! facebook_connect works beautifully if I call anything in a separate view file in my controller like so:

    function facebookconnect()
{
  $this->load->library('facebook_connect');
    $data = array(
        'user'        => $this->facebook_connect->user,
        'user_id'    => $this->facebook_connect->user_id
        );


  $this->template->write_view('content','fbtest',$data);
  $this->template->render();
}

this works no problem calling it from it's own page and everyone is happy. But when I try to put my facebook interactivity into a div on my homepage with this code:

function index()
{
    $this->load->library('facebook_connect');

    $data = array(
        'user' => $this->facebook_connect->user,
        'user_id' => $this->facebook_connect->user_id
        );
    $this->template->write_view('content','indexpage',$data);
    $this->template->render();
}

My homepage loads fine but I have this error:

A PHP Error was encountered

Severity: Notice Message: Undefined variable: user_id Filename: views/indexpage.php Line Number: 32

This i think is strange as it works with code above. My variables are passed so I don't get it. What I want to achieve is that on the homepage a list of facebook friends should appear when page loads. Is there anything i should know about this library? I went through the userguide looking for to see if i could write a separate view to the div that should carry the facebook connect results. Here is my view code just incase it will help:

php if ( !$user_id ): php else: " /> Hi php$user['first_name']!
(Logout) php endif; Here's some comments! [removed] FB.init("$this->config->item('facebook_api_key')", "/xd_receiver.htm"); [removed]

A: 

The problem seems to be in this line:

user_id' => $this->facebook_connect->user_id

because facebook's PHP client doesn't have any user_id property. The user id is available from:

user_id' => $this->facebook_connect->user

So try removing the line:

'user_id' => $this->facebook_connect->user_id
Sarfraz
hey sac,sorry but it did not work, tried taking the line out and still nothing. thanks for trying anyways.
Eagletrophy