When does Autoload Happen? |
[eluser]Zack Kitzmiller[/eluser]
I'm trying to write a hook, that determines the subdomain, and pulls account information based on that 37Signals style, but it seems that autoload's no longer work. If I load all models by hand in the pre-controller hook, it works fine, for some reason autoload doesn't work. Or maybe I'm doing this all wrong and should have build a library or something. I'm starting to go crazy over this. Who's got suggestions?
[eluser]Dam1an[/eluser]
In which hook are you trying to do this? The autoloading takes place between the pre_controller and post_controller_constructor hook, so if you're doing pre_controller, you won't have the stuff autoloaded yet Is there any reason why you couldn't just do this in the MY_Controller constructor?
[eluser]Zack Kitzmiller[/eluser]
[quote author="Dam1an" date="1245786650"]In which hook are you trying to do this? The autoloading takes place between the pre_controller and post_controller_constructor hook, so if you're doing pre_controller, you won't have the stuff autoloaded yet Is there any reason why you couldn't just do this in the MY_Controller constructor?[/quote] I really just jumped into this last night with out putting a ton of though into it. Building MY_Controller would be the best way to handle this you think?
[eluser]Dam1an[/eluser]
[quote author="techneke" date="1245786734"]Building MY_Controller would be the best way to handle this you think?[/quote] 'Best' is such a subjective word. I would rather do it in MY_Controller for 2 reasons 1) I prefer MY_Controller over hooks (although there are certain times I find a hok more convenient) 2) I would probably want to set some variables in the scope of MY_Controller based on what I do with the subdomain/account info Although this is just speculation/personal preferance at this stage, as I don;t really know too much about what you're doing
[eluser]Zack Kitzmiller[/eluser]
[quote author="Dam1an" date="1245788668"][quote author="techneke" date="1245786734"]Building MY_Controller would be the best way to handle this you think?[/quote] 'Best' is such a subjective word. I would rather do it in MY_Controller for 2 reasons 1) I prefer MY_Controller over hooks (although there are certain times I find a hok more convenient) 2) I would probably want to set some variables in the scope of MY_Controller based on what I do with the subdomain/account info Although this is just speculation/personal preferance at this stage, as I don;t really know too much about what you're doing[/quote] Would you mind having a small chat over DM or AIM, i'd be interested in your input on a couple things.
[eluser]Dam1an[/eluser]
ok, I'll send you a PM in a minute with my MSN (no way am I putting my email on these spam ridden forums ) And only on the condition you summarise your findings here, so everyone can benefit (should anyone else want to do something similar)
[eluser]Mahmoud M. Abdel-Fattah[/eluser]
I've the SAME QUESTION now, and I used MY_Controller, but I faced a problem. If user visit : http://username.domain.com/ http://other-username.domain.com/ (WITHOUT any CONTROLLER NAME) MY_Controller will be loaded, then default controller, and I can manage everything. so if user access : but IF user visit : http://other-username.domain.com/any-word-here/ (WITH any CONTROLLER NAME) MY_Controller wont be loaded, and 404 error will be shown cause there's no (any-word-here) controller. so now, I want to make my code run even before CodeIgniter look for controllers. after searching, I found I should use hooks, but I've another questions, can I use CodeIgniter Libraries & Helpers in hooks ?? I mean can I use the following code in hook ? Code: $query = $this->db->query('SELECT `subdomain` FROM `retailers` WHERE `subdomain`=' .$this->db->escape($this->config->item('user_base_url'))); |
Welcome Guest, Not a member yet? Register Sign In |