Developer DocumentationDear developer, Joomla! is not only the best CMS because of its core team; Joomla! is empowered by all the third-party extensions, professional or not, which add so many functionalities to any website.
IntroductionAcyMailing uses the Joomla Plugin system to handle its tag system. So the first thing you have to do is to create a standard Joomla plugin with the group "acymailing" and install it on Joomla.
Create a newsletter tagWe recommend you to download and install our fully commented example plugin : You can then modify the installed file plugins/acymailing/example.php and plugins/acymailing/example.xml to meet your needs.
acymailing_getPluginType()This function enables AcyMailing to display your tag on our tag system (on the interface after you click on the button "Tag"). If you want to have a tag interface, you have to return us an object with :
Your own function nameUsing the function acymailing_getPluginType, you returned to AcyMailing a name and an unique function name to call. On the following screenshot, we called it acymailingMyUniqueNameFunction.
//This is the function name I specified in the previous $onePlugin->function argument.
//This function will be triggered if my tab is selected on the interface
//If you don't want an interface on the tag system, just remove this function
function acymailingMyUniqueNameFunction(){
//In this file you can use the javascript function setTag('your tag'); and insertTag(); which will set the tag and insert it in your Newsletter.
//Please only use insertTag() if you want the tag to be direclty inserted but if you use only setTag('your tag') then the user will be able to see it and click on the insert button.
//Your content will be inserted inside a form, you can add a submit button or whatever you want, it will do the job (if you want to add a search option).
echo '<div onclick="setTag(\'{myowntag}\');insertTag();">Click here to insert my tag</div>';
}You don't have to return anything. AcyMailing makes your life easier and handles the tag insertion.
Please don't add a form on your tag interface, AcyMailing already did it so you can directly add some submit button if you want to give the possibility to the user to search or sort your columns.
acymailing_replacetags(&$email,$send=true)This function enables you to replace your global tags. What we call global tags is a tag which does not depend on the user information. AcyMailing will trigger this function during the preview and only one time during the send process. There are two parameters for this function:
You don't have to return anything, simply directly modify the Newsletter the way you want. Show / hide php code
acymailing_replaceusertags(&$email,&$user,$send=true)This function enables you to replace your personal tags. AcyMailing will trigger this function each time an e-mail is sent or displayed (on the archive version for example) for each user. The last parameter $send enables you to know if the Newsletter will be sent (set to true) or displayed on the browser (set to false)
acymailing_generateautonews(&$email)This function enables you to accept or block a Newsletter generation from our auto-Newsletters feature. You can use the email object and you can access the latest generated date with $email->params['lastgenerateddate'] (this value is a timestamp but won't exist if you trigger this function from somewhere else) You should return an object with:
Create a filterYou can add your own filters to our filter interface. onAcyDisplayFilters(&$type)This function enables you to add a new filter type on our filter interface. You should return a string which will be displayed on the filtering interface and add a new type in $type variable. Then if your filter is selected, the function onAcyProcessFilter_YOURTYPE(&$query,$filter,$num) will be triggered. Please have a look at our existing plugins (tagsubscription or tagsubscriber to have an example). Create an actionYou can add your own actions to our filter interface. onAcyDisplayActions(&$type)This function enables you to add a new action type on our filter interface. You should return a string which will be displayed on the filtering interface and add a new type in $type variable. Then if your filter is selected, the function onAcyProcessAction_YOURTYPE(&$query,$action,$num) will be triggered. Please have a look at our existing plugins (tagsubscription or tagsubscriber to have an example).
Other plugin triggersWhen the user is createdWhen the user is created, the function onAcyUserCreate($subscriber) is triggered. When the user is modifiedWhen the user is modified, the function onAcyUserModify($subscriber) is triggered. When the user subscribes to a listWhen the user subscribes to a list, the function onAcySubscribe($subid,$listids) is triggered. When the user unsubscribes from a listWhen the user unsubscribes from a list, the function onAcyUnsubscribe($subid,$listids) is triggered. When a Newsletter is added to the queueWhen the Newsletter is added to the queue, just before the send process starts, the function onAcySendNewsletter($mailid) is triggered Cron triggerUsing our commercial version (if you created your cron task), AcyMailing will trigger the function onAcyCronTrigger every day automatically. So you can create a Joomla plugin type AcyMailing with this function and it will be automatically triggered once a day (only once a day even if your cron has a 15 minutes frequency). There is no argument for this function but you can return a string which will be automatically included in the cron report.
APIGet the AcyMailing mailing listsif(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$listClass = acymailing_get('class.list');
$allLists = $listClass->getLists();
//You can then do a foreach on this variable (which contains an array of objects) and use ->name
Insert a user in AcyMailingif(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$myUser = new stdClass();
$myUser->email = 'emailaddressoftheuser';
$myUser->name = 'myname'; //this information is optional
//You can add as many extra fields as you want if you already created them in AcyMailing
//$myUser->country = 'france';
//$myUser->phone = '064872754';
//...
$subscriberClass = acymailing_get('class.subscriber');
$subid = $subscriberClass->save($myUser); //this function will return you the ID of the user inserted in the AcyMailing table
Subscribe or remove a user from one or several lists$subscribe = array(2,4,6); //Id of the lists you want the user to be subscribed to (can be empty)
$remove = array(1,3); //Id of the lists you want the user to be removed from (can be empty)
$memberid = '23'; //ID of the Joomla User or user e-mail (this code supposes that the user is already inserted in AcyMailing!)
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$userClass = acymailing_get('class.subscriber');
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList['status'] = 1;
$newSubscription[$listId] = $newList;
}
}
if(!empty($remove)){
foreach($remove as $listId){
$newList = array();
$newList['status'] = 0;
$newSubscription[$listId] = $newList;
}
}
if(empty($newSubscription)) return; //there is nothing to do...
$subid = $userClass->subid($memberid); //this function returns the ID of the user stored in the AcyMailing table from a Joomla User ID or an e-mail address
if(empty($subid)) return false; //we didn't find the user in the AcyMailing tables
$userClass->saveSubscription($subid,$newSubscription);
Create a Newsletter
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
//We create the Newsletter element that we will save in the database.
//You can use all fields from the database the same way we do it with subject and body.
$mail = new stdClass();
//Subject of your Newsletter
$mail->subject = 'your subject...';
//Body of your Newsletter... the text version will be automatically generated from this html version.
$mail->body = 'your body...';
//ID of the template attached to this Newsletter so the CSS defined in that AcyMailing template will be applied to your Newsletter.
$mail->tempid = 4;
$mailClass = acymailing_get('class.mail');
//the save function returns you the ID of the inserted Newsletter so you can then use it to insert e-mails in the queue.
$mailid = $mailClass->save($mail);
Insert an e-mail in the queue//The purpose of this code is to let AcyMailing send an e-mail to a specific user at a specific time.
//You just have to add an entry in the queue and AcyMailing will take care of the rest.
$memberid = '23'; //ID of the Joomla User or user e-mail (this code supposes that the user is already inserted in AcyMailing!)
$mailid = '45'; //ID of the Newsletter you want to add in the queue
$senddate = time(); //When do you want the e-mail to be sent to this user? you should specify a timestamp here (time() is the current time)
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$userClass = acymailing_get('class.subscriber');
$subid = $userClass->subid($memberid); //this function returns the ID of the user stored in the AcyMailing table from a Joomla User ID or an e-mail address
if(empty($subid)) return false; //we didn't find the user in the AcyMailing tables
$db= JFactory::getDBO();
$db->setQuery('INSERT IGNORE INTO #__acymailing_queue (`subid`,`mailid`,`senddate`,`priority`) VALUES ('.$db->Quote($subid).','.$db->Quote($mailid).','.$db->Quote($senddate).',1)');
$db->query();
Create a list
$newlist = new stdClass();
$newlist->name = 'Your list name';
$newlist->description = 'Your list description'; //this parameter is optional
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$listClass = acymailing_get('class.list');
$listid = $listClass->save($newlist); //This function will create the list and return the ID of the created list
Delete a list
//This code will not only delete a list an all elements related to that list (it won't delete users or newsletters, but only the fact a Newsletter is attached to that list or a subscriber subscribed to that list)
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This code can not work without the AcyMailing Component';
return false;
}
$listClass = acymailing_get('class.list');
$listClass->delete(LIST_ID); //You should replace LIST_ID by the ID of the list you want to delete
Last Updated on Thursday, 04 April 2013 16:08
|




Enjoy automatic send process and scheduled newsletters. Use captcha and welcome messages.
Stop writing your newsletters, let Acy do it for you! Track your user's clicks and get powerful statistics.
The ultimate version with custom fields, front-end edition, bounce back handling, follow-up messages ...
The best of AcyMailing with unlimited websites support.
More integrations? Have a look at our plugins
AcyMailing is translated in more than 40 languages
AcyMailing
If our documentation didn't answer your question
Where everything is explained!
For private enquiries

