-
Notifications
You must be signed in to change notification settings - Fork 41
Integrating with extensions
To use TJ Notifications, you need to install the library along with your extension.
Include the library file
jimport('techjoomla.tjnotifications.tjnotifications');
Prepare the parameters for Tjnotifications::send()
$client is the name of your extension, eg: com_jgive
$key is the unique reference for the type of email within your extension. Eg: donation.thankyou, campaign.update, order.thankyou
$recipients is an array of JUser objects
eg: $recipients = JAccess::getUsersByGroup(2);
$replacements is an object of objects, containing all replacements. The object and their properties are mapped against the values in the template body. $replacements->order->id maps to {order.id} for example.
$options is an instance of JParameter. Contains additional options that may be used by the notification provider. In case of email options may include cc, bcc, attachments, reply to,from,guestEmails etc
Finally, call Tjnotifications::send($client, $key, $recipients, $replacements, $options); This will send the notifications based on user preferences. If the user has disabled any of the notifications or specific delivery preferences, those notifications will not be sent to the user. The 3rd party developer does not need to be aware of these settings.
<?php
public function save($data)
{
$client = "com_jcregister";
$key = "order";
$recipients[] = JFactory::getUser(488);
$recipients[] = JFactory::getUser(489);
$order_info->id = "236";
$order_info->amount = "500";
$order_info->status = "Pending";
$replacements->order = $order_info;
$customer_info->name = "hemant";
$customer_info->address = "";
$customer_info->zip = "411004";
$replacements->customer = $customer_info;
$options = new JParameter();
$options->set('cc', 'demo@mailinator.com');
$options->set('attachment', '/var/www/html/joomla/media/attach.pdf');
$options->set('guestEmails', array("testuser@mailinator.com"));
$options->set('from', "pranoti_p@techjoomla.com");
$options->set('fromname', "pranoti");
Tjnotifications::send($client, $key, $recipients, $replacements, $options);
}