CodeIgniter Forums
My own classes and the code used everytime - 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: My own classes and the code used everytime (/showthread.php?tid=12834)



My own classes and the code used everytime - El Forum - 11-01-2008

[eluser]Rvnikita[/eluser]
Hi!
First off all thanks you very much because ofCodeigniter.
I use it and i like it, but I have 2 questions:

1) I have some code, that I used everytime on site, for example some initial code, that i must call in every controller in every function (before the execution)
Now I made a init model and in every controller first off all i call it
Code:
$this->load->model('init_m');
$this->init_m->make_init();

How can I wrote init code, that will be automaticly call before any controller?

2) I need some class, for example user class with different params and functions.
Code:
$user->name, $user->surname, $user->is_18_year_old()
How can i do it right?

Thank's you very much and sorry for my english .(


My own classes and the code used everytime - El Forum - 11-01-2008

[eluser]Colin Williams[/eluser]
Create a pre_controller hook: http://ellislab.com/codeigniter/user-guide/general/hooks.html


My own classes and the code used everytime - El Forum - 11-02-2008

[eluser]Rvnikita[/eluser]
[quote author="Colin Williams" date="1225604759"]Create a pre_controller hook: http://ellislab.com/codeigniter/user-guide/general/hooks.html[/quote]

OOh! Thanks you very very much!