CodeIgniter Forums
Loader isnt loading -.- - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Loader isnt loading -.- (/showthread.php?tid=52406)



Loader isnt loading -.- - El Forum - 06-09-2012

[eluser]nagata[/eluser]
Could someone help with this
Code:
<?php
$this->load->model('auth_model');
$ident=$this->session->userdata('ident');
if ($this->session->userdata('logged_in')==true) {
$this->auth_model->i_am_on($ident[1]['id']);}
?>
Its located in file views/templates/prefab.php
Its small php code that determines user is online currently.
it was working when it was in views/auth/index.php (User List)
But stoped working in other documents... I tried to place it EVERYWHERE, but sadly there was no result for it to work excep this error
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$auth_model

Filename: templates/prefab.php

Line Number: 5


Fatal error: Call to a member function i_am_on() on a non-object in C:\xampp\htdocs\application\views\templates\prefab.php on line 5

could someone explain me this black CI humor and make it work? I been trying to make it work like 2 hours now -.-


the i_am_on() function
Code:
public function i_am_on($id)
{
if ($this->session->userdata('logged_in')==true){
$data = array('lastseen' => time(),);
$this->db->where('id', $id);
$this->db->update('users', $data);
}
}



Loader isnt loading -.- - El Forum - 06-09-2012

[eluser]Samus[/eluser]
You need to seriously go read the CI user guide and understand it.

Loading in a view? Seriously?

Start here: http://ellislab.com/codeigniter/user-guide/overview/mvc.html
Then here: http://ellislab.com/codeigniter/user-guide/general/views.html


Loader isnt loading -.- - El Forum - 06-09-2012

[eluser]nagata[/eluser]
your reply sorta helped me to get the idea of adding the auth_model into autoload config...
so yeah thank you.


Loader isnt loading -.- - El Forum - 06-09-2012

[eluser]Samus[/eluser]
[quote author="nagata" date="1339239650"]your reply sorta helped me to get the idea of adding the auth_model into autoload config...
so yeah thank you.[/quote]
Glad to help. Smile

But my point was that you should be loading from within your controller.


Loader isnt loading -.- - El Forum - 06-09-2012

[eluser]nagata[/eluser]
I had it loading in controller didnt help either... anyways solved/should be closed.