Welcome Guest, Not a member yet? Register   Sign In
autoload not working correctly
#4

(This post was last modified: 10-27-2015, 09:38 AM by joseph.dicdican.)

(09-29-2015, 11:35 AM)mcgiwer Wrote: Welcome. I think I had found a bug in autoload. In the configuration I had added to autoload all needed libs (like by example "html", "url" with I needed).

After I wrote the code, I recieved error about call to unknown functions (with I got from the documentation for the html and url helpers). I solved it by typing on the code top:


Code:
$this->load->helper('html');
$this->load->helper('url');

This would mean that the autoloader don't work because before I entered the above code, the libs weren't automacially loaded as they should be.

Hi,

I would just like to clarify where did you put the codes (e.g. $this->load->helper('html') ...). 
You have mentioned,  In the configuration I had added to autoload all needed libs (like by example "html", "url" with I needed). 

I assumed you are writing the loading codes to some other file not controller nor model. If that's the case, you cannot really call $this->load->helper since $this is not referenced to any object specifically to CI singleton instance. (e.g. $CI =& get_instance())

Please consider the link for more info. http://tosbourn.com/codeigniter-use-get_instance/
You can find these statements below.
Quote:If however you are writing your own custom libraries or something that sits outside of the MVC files then you do need to use it.

So, if you are inside a model you could do something like this;


Code:
$this->load->library('my_cool_library')

But if you are in a class you have written yourself then the $this object will not know about the CodeIgniter stuff, so you would do something like this;

Code:
$ci=& get_instance();
$ci->load->library("my_cool_library")
We use 

Code:
=&

 because we don't want to make a new copy of the CodeIgniter object, we want to use the original one.


I hope these have sense. Thank you.
- joseph.dicdican  Smile
Joseph K. Dicdican
Softshore Global Solutions Inc. | Junior Web Developer Intern
Passerelles numériques Philippines | Scholar
[email protected] 
Reply


Messages In This Thread
autoload not working correctly - by mcgiwer - 09-29-2015, 11:35 AM
RE: autoload not working correctly - by Muzikant - 09-30-2015, 01:29 AM
RE: autoload not working correctly - by Narf - 09-30-2015, 03:31 AM
RE: autoload not working correctly - by joseph.dicdican - 10-27-2015, 09:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB