Using Helpers inside own Libraries |
[eluser]uk81[/eluser]
Hi. I have a little problem. It is more a problem with the documentation than with the code itself. I load the url-helper inside my own library like the documentation shows: http://ellislab.com/codeigniter/user-gui...aries.html (s. Utilizing CodeIgniter Resources within Your Library) So I load the helper with: Code: $this->ci =& get_instance (); and then use it with: Code: $this->ci->anchor (); Code: $this->ci->base_url (); This is how it is explained in the documentation, but does not work in this way. I was testing and trying and now found out that I use it in a other Library already in this way, totally different from explained in the documentation: Code: anchor (); Code: site_url (); It is totally confusing, because the documentation seems to be false or I make something totally false. If noone can explane it to me or knows why it works in that way, I will report a documentation bug. Thanks. ![]()
[eluser]xwero[/eluser]
the $this->ci-> syntax is used when you load a model or library and use the methods of them. A helper is a file with functions in it.
[eluser]uk81[/eluser]
Ah I see ... I oversee, that helpers, libraries and models are also used inside a library as they will be used in a controller. Only when the instance is called (in a controller with $this->) the variable as a reference to the instance inside the library is used. My fault. ![]() |
Welcome Guest, Not a member yet? Register Sign In |