[eluser]joeizang[/eluser]
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:
Code:
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:
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:
Code:
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:
Code:
<div class="entry">
<p>
<?php if ( !$user_id ): ?>
<fb:login-button></fb:login-button>
<?php else: ?>
<img class="profile_square" src="<?=$user['pic_square']?>" />
Hi <?=$user['first_name']?>!<br />
<a href="#">(Logout)</a>
<?php endif; ?>
<h2 class="title">Here's some comments!</h2>
<fb:comments title="Facebook Connect Test" width="520px"></fb:comments>
[removed]
FB.init("<?=$this->config->item('facebook_api_key')?>", "/xd_receiver.htm");
[removed]
</p>
</div>