![]() |
I'm probably doing something stupid but it seems to be autoloading my helper class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: I'm probably doing something stupid but it seems to be autoloading my helper class (/showthread.php?tid=62097) |
I'm probably doing something stupid but it seems to be autoloading my helper class - DreamOfSleeping - 06-09-2015 Hi. I have a helper class called my_url_helper. This has some simple functions called css_url, js_url, and image_url to help me load them. It works great. Then I noticed I had forgot to load the helper on half my pages, but it still works and I don't know why. Things I've tried. I checked and double checked the autoload file to make sure I hadn't added it to it. I haven't I commented out all the parts in my code where I load the helper in case codeigniter somehow remembered it. It still works. I wondered if the file had just been cached or something, so I added another function to the helper class called poo_face that simple returns a string saying "pooooooo face". I added a call to the poo_face function, and it worked despite the helper not being loaded. I thought I would ask here in case there is something that I might have overlooked. Here is a one of my controllers and the view that has the functions. PHP Code: <?php Code: <!DOCTYPE html> RE: I'm probably doing something stupid but it seems to be autoloading my helper class - Blair2004 - 06-09-2015 If you mean "MY_helper_class", it means you are overriding codeigniter class by that way it always loaded... Try this, change classes prefix on "config.php" file, and the class won't be loaded anymore... cheers... RE: I'm probably doing something stupid but it seems to be autoloading my helper class - DreamOfSleeping - 06-09-2015 Thanks for the reply. To clarify - Are you saying that whenever you add the word "my" to a helper class that is already in the codeigniter framework it overrides it? If that's true then I'll just change the name of my class. I've now changed the name of "my_url_helper" to "assets_url_helper" and that has fixed the problem. Thanks again! RE: I'm probably doing something stupid but it seems to be autoloading my helper class - DreamOfSleeping - 06-09-2015 (06-09-2015, 03:49 AM)DreamOfSleeping Wrote: Thanks for the reply. To clarify - Are you saying that whenever you add the word "my" to a helper class that is already in the codeigniter framework it overrides it? If that's true then I'll just change the name of my class. I've now changed the name of "my_url_helper" to "assets_url_helper" and that has fixed the problem. Thanks again! Having said that. Overriding it wouldn't necessarily be a bad thing so I might change it back. RE: I'm probably doing something stupid but it seems to be autoloading my helper class - DreamOfSleeping - 06-09-2015 And I've just read the instruction about the extending helper classes thing now, so no need to clarify. RE: I'm probably doing something stupid but it seems to be autoloading my helper class - Blair2004 - 06-09-2015 That's seem to be simple indeed, every time you intent to extends a core class, this one override automaticaly without any special include. Just use the class prefix defined on config.php file and it's done. I think you sould create a custom library instead and drop that file on "library/" folder, so it would be easy for you to include it on each controllers or on specifics. RE: I'm probably doing something stupid but it seems to be autoloading my helper class - gadelat - 06-09-2015 Helpers in CI are not classes, I don't know what are you two talking about. If you need to find info about what is loaded when, modify log_treshold value. RE: I'm probably doing something stupid but it seems to be autoloading my helper class - Blair2004 - 06-10-2015 That's nice said... |