Extend Notification Send (email) functionality

edited May 2017 in Modules
I tried a form in settings which defines a email settings like smtp host etc.. and I succeeded in that but I want to extend send functionality in notification library. Can anyone give some idea on this this is my first day with fuelcms.

Comments

  • edited 6:29PM
    By notification library are you referring to the Fuel_notification library (which is essentially just a wrapper around the CI_Email class)?
  • edited 6:29PM
    Yes Fuel_notification library.
    "Send new user invite" functionality I wanted to extend.

    i.e. there is a form created via new module in settings for email settings which covers the fields like all email settings .. (from name, smtp, email etc...) which will be used to send email when the send function of file > modules\fuel\libraries\Fuel_notification.php is called.

    For that purpose I need to extend this library, but failed to do this. Just needed some guide/tips for this kind of functionality.

    Thanks.
  • edited 6:29PM
    You can extend the Fuel_notification library and then when you want to overwrite it, use the attach method. Example below:
    $my_notification = new MY_Notification(); $CI->fuel->attach('notification', $my_notification);
  • edited 6:29PM
    Ok. Will try that.
  • edited August 2017
    Hello.
    I think I am getting very noob here.
    Let me explain my issue.
    Final Goal:
    When resetpassword/new invite is called it should also send email to admin who has different smtp details. So, I want to extend it.

    What I did:
    I have created a file in \application\libraries\MY_Notification.php which starts like...

    require_once(FUEL_PATH.'libraries/Fuel_notification.php');
    class My_notification extends Fuel_notification

    and this new file also do have a send function just like modules\fuel\libraries\Fuel_notification.php file has one.

    Now I was hoping that when send function is triggered, it will call from My_notification function and which is not getting called for obvious reason.

    But I am not getting how to solve it.
  • edited 6:29PM
    Where did you put the code:
    $my_notification = new MY_Notification(); $CI->fuel->attach('notification', $my_notification);
  • edited 6:29PM
    I put in modules\fuel\libraries\Fuel_notification.php and didn't work. But 2 things I am sure that
    - that is the wrong location of the code
    - and there will/should not be any changes in Fuel_notification.php.
  • edited 6:29PM
    Try adding this to your fuel/application/config/MY_fuel.php file:
    $config['attach'] = array('notification' => new MY_Notification());
Sign In or Register to comment.