[eluser]solid9[/eluser]
Hi guys
Is creating My_Controller is good only for extending Native Libraries?
Or can I use it as ordinary controller?
What's the right way to name the My_Controller file?
Thanks in advanced.
[eluser]qcsites[/eluser]
You should follow the directions exactly in the link exactly. The controller needs to be named MY_Controller in order for it to be extended.
You should then return the data you will want to use in controllers you extend from the MY_Controller.
So your MY_Controller file name would be MY_Controller.php as shown.
Then the extended controllers operate as normal controllers, but for things you need site wide in all controllers, you can put that in the MY_Controller. Stuff like session management, site settings stuff etc.
[eluser]CroNiX[/eluser]
You still didn't do it right because you didn't follow the guide exactly, which is important.
Its called MY_Controller, not MY_Primary, and it gets put in /application/core/MY_Controller.php
Also, you don't call it directly. It is automatically loaded when you call a controller. Its just a way to add methods that will be available to all controllers, that extend MY_Controller.
Then, for your own controllers, they extend MY_Controller, instead of CI_Controller.
If you follow the guide exactly, it will work. If you alter it, it won't.
[eluser]CroNiX[/eluser]
You will also have problems like you are having with the "cannot modify headers" if you echo from a base controller. That should be done from views.