I wanted to use PHP list but did not want a complicated expensive full integration. There are limitations involved;
- Joomla subscribers will not be automatically subscribed to phplist. For this you will need a phplist-bridge or full integration package.
- simple integration with just one newsletter
I have to say that much of this article was inspired by Jesse Kanclerz's web article.
1. Installs
To get started you will need to install:
- Chronoforms component (enable mootools upgrade plugin)
- Install Chronoforms plugin
- Install PHP list on your host server, my default install directory was [domain]/newsletter.
- Note: Joomla version 1.5.15, PHP list version 2.10.13
2. Set up PHP list
- Create at least one list
- Add any user attributes (I added "First name" and "Last name")
3. Create subscribe form
Within Joomla create a subscribe form using chronoforms. Mine was called "phplist". Under the code tab use form type > "wizard". In the HTML space cut and paste the source code from the subscribe page in phplist, you will take out the form tags mine looked like this;
<table border=0>
<tr><td><div>Email</div></td>
<td><input type=text name=email value="" size="40">
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
<tr><td><div>Confirm your email address</div></td>
<td><input type=text name=emailconfirm value="" size="40">
<script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm your email address");</script></td></tr><tr><td colspan=2>
<span><input type=checkbox name="htmlemail" value="1" /></span>
<span>I prefer to receive emails in HTML format</span></td></tr>
<tr><td><div>First name</div></td><td>
<input type=text name="attribute1" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute1","First name");</script></td></tr>
<tr><td><div>Last name</div></td><td>
<input type=text name="attribute2" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Last name");</script></td></tr>
</table>
<input type="hidden" name="list[1]" value="signup"><input type="hidden" name="listname[1]" value="BeanBox Bike Rental news"/><div style="display:none"><input type="text" name="VerificationCodeX" value="" size="20"></div><p><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
<br/><br/>
<p><a href="http://beanboxbikerental.com/newsletter/?p=unsubscribe&id=1">Unsubscribe</a></p>
</div>
</td>
<td>
In chronoforms click on the wizard edit link, change to advanced mode...on the right click on the code tab and "Load JS". Cut and paste the javascript from the phplist subscribe form. Mine looked like this;
function checkform() {
for (i=0;i<fieldstocheck.length;i++) {
if (eval("document.ChronoContact_Phplist['"+fieldstocheck[i]+"'].type") == "checkbox") {
if (document.ChronoContact_Phplist[fieldstocheck[i]].checked) {
} else {
alert("Please enter your "+fieldnames[i]);
eval("document.ChronoContact_Phplist['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
else {
if (eval("document.ChronoContact_Phplist['"+fieldstocheck[i]+"'].value") == "") {
alert("Please enter your "+fieldnames[i]);
eval("document.ChronoContact_Phplist['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
}
for (i=0;i<groupstocheck.length;i++) {
if (!checkGroup(groupstocheck[i],groupnames[i])) {
return false;
}
}
if(! compareEmail())
{
alert("Email Addresses you entered do not match");
return false;
}
return true;
}
var fieldstocheck = new Array();
var fieldnames = new Array();
function addFieldToCheck(value,name) {
fieldstocheck[fieldstocheck.length] = value;
fieldnames[fieldnames.length] = name;
}
var groupstocheck = new Array();
var groupnames = new Array();
function addGroupToCheck(value,name) {
groupstocheck[groupstocheck.length] = value;
groupnames[groupnames.length] = name;
}
function compareEmail()
{
return (document.ChronoContact_Phplist["email"].value == document.ChronoContact_Phplist["emailconfirm"].value);
}
function checkGroup(name,value) {
option = -1;
for (i=0;i<document.ChronoContact_Phplist[name].length;i++) {
if (document.ChronoContact_Phplist[name][i].checked) {
option = i;
}
}
if (option == -1) {
alert ("Please enter your "+value);
return false;
}
return true;
}
Make sure that the submit URL tab in your form relates back to phplist, in my case it was;
http://www.beanboxbikerental.com/newsletter/?p=subscribe
You now have a subscribe form in Joomla that is linked to the phplist database. All you need to do is create a Joomla article and include the form using this tag;
{chronoforms}phplist{/chronoforms}
4. Further work
There is the subscribe thankyou and also the subscribe confirm that will need to be worked on (see separate article). The unsubscibe form will need to be completed in a similar way
Source/credits:
Jesse Kanclerz
http://www.jessekanclerz.com/
http://www.jessekanclerz.com/blog/2008/02/how-to-integrate-a-phplist-subscribe-page-into-joomla/