[eluser]TheFuzzy0ne[/eluser]
Controller:
Code:
class Profiles extends Controller
{
function Profiles()
{
parent::Controller();
$this->load->model('Profile_Model', 'profile');
}
function index()
{
if ( !$user = $this->uri->segment(1))
{
$user = "home";
}
//START of twitter section
$ti = $this->profile->twitter_info_public($user); // Get the data from the model method - changed
print_r($ti);
$this->load->library('twitter'); // Load the library
$config = array(
'userid' => $ti['id'], // changed
'username' => $ti['username'], // changed
'type' => 'mine',
'num' => 5,
'rss_cache_path' => APPPATH.'cache/twitter-rss-cache',
'cache_time' => 300 // 5 minutes
);
// $config['type'] can be 'mine' (just your own tweets),
// or 'social' (includes people you follow)
$this->twitter->init($config);
$data['tweets'] = $this->twitter->get_latest();
//END of twitter section
if($this->template['profile'] = $this->profile->get($user))
{
$this->load->vars($this->template);
$this->load->view('profile.php', $data);
}
}
Model:
Code:
class Profile_Model extends Model
{
function Profile_Model()
{
parent::Model();
$this->table = "users";
}
function get($user)
{
$this->db->where('username', $user);
$query = $this->db->get($this->table, 1);
if($query)
{
if($query->num_rows() == 1)
{
return $query->row_array();
}
else
{
$data['error_msg'] = "The user <strong>".$this->uri->segment(1)."</strong>, does not exist! Please check your spelling.";
$this->load->view('error', $data);
}
}
}
function twitter_info_public($user)
{
$this->db->where('username', $user); // Set the WHERE condition
$query = $this->db->get($this->table, 1); // Return the result row
return $query->row_array();
}
The above code is
untested.