Hello all!
I uploaded code from git into my site but having an issue anchoring the controller to view. This is my anchor:
<?= anchor('chat/index','Chat');?>
This is the controller/function that Im trying to connect:
class Chat extends Controller {
function Chat() {
parent::Controller();
$this->load->database('cultured_codeignite');
$this->load->model('mod_chat');
$this->load->library(array('session', 'authentication'));
}
function index() {
//outsiders keep out
$this->authentication->sentry();
$ctr = 0;
//get all chat messages from buddy
$username = $this->session->userdata('username');
$recipient = $this->session->userdata('recipient');
$fetchchat = $this->mod_chat->fetchchat($username, $recipient);
$chatreverse = '';
//reverse results of chat, bottom message is latest
foreach ($fetchchat as $chatorig) {
$chatreverse[$ctr]['username'] = $chatorig->username;
$chatreverse[$ctr]['message'] = $chatorig->message;
$time = explode(' ', $chatorig->time);
$reformat_time = date("g:i a", strtotime($time[1]));
$chatreverse[$ctr]['time'] = $reformat_time;
++$ctr;
}
$data['chat'] = '';
$data['buddy'] = $this->session->userdata('recipient');
$buddyimage = $this->mod_chat->get_buddy_image($this->session->userdata('recipient'));
$data['buddyimage'] = $buddyimage[0]->image;
//throw messages to view
if (is_array($chatreverse)) {
$users['username'] = $username;
$users['recipient'] = $recipient;
$this->mod_chat->message_read($users);
$data['chat'] = array_reverse($chatreverse);
}
$this->load->view('view_chat', $data);
}
The viewer is view_chat that Im trying to connect to. How do I get this to work?
,
Mekaboo