Using functions from My_library in controller |
[eluser]Unknown[/eluser]
Hi, I've created my own custom library (application/libraries/MY_Send_email.php) which extends CI_email. I did this as I will be using email functionality a lot in my website. So far within this class I have a function named sendActivation. How do I call this function from my controller? Below I have my class code and below it my controller code. Any help would be awesome. Thanks! Here is the error I get. Severity: Notice Message: Undefined property: MY_Send_email::$email Filename: libraries/MY_Send_email.php Line Number: 19 Fatal error: Call to a member function from() on a non-object in C:\wamp\...\application\libraries\MY_Send_email.php on line 19 //LIBRARY class MY_Send_email extends CI_Email { function __construct() { $CI =& get_instance(); parent::CI_Email(); } function sendActivation(){ line 19 $this->email->from('[email protected]', 'hi'); } } //CONTROLLER function __construct() { parent::Controller(); $this->load->library('email'); $this->load->library('MY_Send_email'); } function whatever(){ $this->my_send_email->sendActivation(); //this is where I get the error }
[eluser]WanWizard[/eluser]
If you extend a core class, it needs to me named properly. In this case, MY_Email. CI will automatically load it when you load the email lbrary. See the user guide on extending core classes.
[eluser]Unknown[/eluser]
Thanks a lot. I will give this a try. Looks like I was making it way harder than it needed to be. |
Welcome Guest, Not a member yet? Register Sign In |