Welcome Guest, Not a member yet? Register   Sign In
loving the MY_Controller, But...
#1

[eluser]amosdesigns[/eluser]
Hi all, I have watch and read several different tuts on setting a MY_Controller and a MY_Model. My questions in which folder should I place the MY_Public_Controller and MY_Backend_Controller for my App? I have been told in the Library folder and then I would need to add some autoload file in the config file. Or should I add it to the core folder?But I'm having it does not autoload the MY_Controller?

Thanks for the help.
Jerome
Amosdesigns.net
#2

[eluser]InsiteFX[/eluser]
They should be placed into the ,/application/core folder.

Also you still need the auto because CI will only see the first main MY_

Here is how it goes:

If the Class you are extending is in ./system/core then it goes into ./application/core
If the Class you are extending is in the ./systm/libraries then it goes into ,/application/libraries
#3

[eluser]amosdesigns[/eluser]
Thanks for the help.
#4

[eluser]kirkaracha[/eluser]
You can also put both MY_Public_Controller and MY_Backend_Controller functions in the same MY_Controller.php file.

Code:
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {
} // MY_Controller

class Admin_Controller extends MY_Controller {
} // Admin_Controller

/* End of file /application/core/MY_Controller.php */
#5

[eluser]InsiteFX[/eluser]
That will break CI Styling Guide Lines
#6

[eluser]kirkaracha[/eluser]
The Style Guide says "Use separate files for each class your add-on uses, unless the classes are closely related." These seem pretty closely related to me.
#7

[eluser]Aken[/eluser]
The style guide is also mainly for released applications / libraries. If it's your application, you can do whatever you want with it. Unfortunately if you want to follow the "style guide" way of doing things, you still need to add some sort of autoload or extended loading class that will look for base controllers in the correct spot.




Theme © iAndrew 2016 - Forum software by © MyBB