Upcoming Events
NYC CiviCRM Meetup - September 7th
September 7th, 2010
This next NYC meetup will feature a case study or 2, a look at what's new in (more...)
Configuring, Customizing and Extending CiviCRM - New York
September 16th, 2010
This comprehensive two-day hands on training course is targeted at (more...)
CiviCRM User and Administrator Training - New York
September 16th, 2010
A comprehensive two day hands on training course covering the configuration, (more...)
CiviCRM Code and Test Sprint - New York
September 18th, 2010
This code and test sprint is targeted at experienced developers who want to (more...)
CiviCRM Toronto Meetup
September 21st, 2010
Come meet others from the Toronto Area who are interested in, using or (more...)
CiviCRM Philly Meetup – September 2010
September 23rd, 2010
Come meet others from the Philadelphia Area who are interested in, using or (more...)
CiviCRM Seminar - Dublin
September 28th, 2010
NfP Services are hosting a free seminar at The IBOA, Stephen St Upper, Dublin 8 (more...)
London developer and implementer training
September 30th, 2010
This comprehensive two-day hands on training course is targeted at implementers, (more...)
London user and administrator training
September 30th, 2010
A comprehensive two day hands on training course covering the configuration, (more...)
Berlin user and administrator training
October 6th, 2010
A comprehensive one day hands on training course covering the configuration, (more...)
Berlin developer and implementer training
October 7th, 2010
This comprehensive one-day hands on training course is targeted at implementers, (more...)
Benelux meetup in Brussels: Connect, communicate and activate your supporters and constituents
October 11th, 2010
Come meet others who are interested in, using or developing for CiviCRM. For (more...)
CiviCRM Toronto Meetup
October 19th, 2010
Come meet others from the Toronto Area who are interested in, using or (more...)
CiviCRM Toronto Meetup
November 16th, 2010
Come meet others from the Toronto Area who are interested in, using or (more...)
Mailing list subscription forms in Drupal blocks
- Not Just a Contact Database
-
These optional components give you more power to connect and engage your supporters.

civiCONTRIBUTE
Online fundraising and donor management.

civiEVENT
Online event registration and participant tracking.

civiMEMBER
Online signup and membership management.

civiMAIL
Personalized email blasts and newsletters.

civiREPORT
Report generation and template management.
The idea of creating a Drupal block containing a subscription form for a specific CiviMail mailing list (or for all of them) comes regularly on the forum, so I decided to try out how much work would it be to create one.
It turns out this task is fairly simple, if one knows the proper URLs for CiviMail subscription pages. The URLs are of the form …civicrm/mailing/subscribe?reset=1 (for all mailing lists) and …civicrm/mailing/subscribe?reset=1&gid=X (for a mailing list with group id of X). For example, these two URLs point to subscription pages on our Drupal demo installation: http://drupal.demo.civicrm.org/civicrm/mailing/subscribe?reset=1 (all mailing lists), http://drupal.demo.civicrm.org/civicrm/mailing/subscribe?reset=1&gid=2 (the Newsletter Subscribers list).
If having a separate page is not really the best outcome, there’s a possibility of creating similar Drupal blocks. The simplest(?) way of doing this is to look at the sources of the above pages, strip them down as much as necessary and then create an HTML Dupal block from the resulting code.
From my quick try, it seems like the below is a nice starting point (for a block listing all groups) – of course, in your case you need to adjust the URL, the names of the lists and their respective ids:
<form action="http://drupal.demo.civicrm.org/civicrm/mailing/subscribe" method="post">
<p>Email: <input name="email" type="text" id="email" /></p>
<table>
<tr>
<td><input name="mark_x_4" type="checkbox" value="1" /></td>
<td>Advisory Board</td>
</tr>
<tr>
<td><input name="mark_x_2" type="checkbox" value="1" /></td>
<td>Newsletter Subscribers</td>
</tr>
<tr>
<td><input name="mark_x_3" type="checkbox" value="1" /></td>
<td>Summer Program Volunteers</td>
</tr>
</table>
<p>
<input name="_qf_Subscribe_next" value="Subscribe" type="submit" />
</p>
</form>
Creating a block for just a single list subscription is even easier – all you need to do is to pass the id as a hidden field:
<form action="http://drupal.demo.civicrm.org/civicrm/mailing/subscribe" method="post">
<p>
Email: <input name="email" type="text" id="email" />
<input type="hidden" name="mark_x_2" value="1" />
<input name="_qf_Subscribe_next" value="Subscribe" type="submit" />
</p>
</form>
If you have any comments or questions on the above, please feel free to join this thread on our forum.
Update: In v2.2 you can also add a hidden field to redirect the user to a specific page once they have subscribed (it will redirect to referer if not specified). The relevant html snippet to add within the form is:
<input type="hidden" name="destination" value="http://www.yahoo.com/" />







Comments
what about other fields?
we want to collect first and last name and also birthdate. those other fields should be optional (maybe name mandatory), but i can't figure out a way to do this. the URL for civimail-subscribe only has the email field on there. am i missing something?
More on additional fields
I also want to capture additional fields (in fact the same ones that you mention). Has anyone got a way of doing this?
Cheers
Martin Fuggle
Support questions on forum please ..
this is better discussed on the forums. You can also use a profile to collect additional fields
This is great and works like
This is great and works like a charm.
redirect?
This is great, thank you for posting this. However, how do you set the "redirect" page (to where you want the person to be redirected to) once the subscriber confirms their subscription from the confirmation email? Also, is it possible to collect additional information, i.e. subscribers zip code?
Best to repost these
Best to repost these questions on the community forum - CiviMail section:
http://forum.civicrm.org/index.php/board,17.0.html
beware
Be aware that by doing it this way (pasting an entire HTML form into a block) you are bypassing Drupal's FormAPI and all the security that goes along with it...
-mike
yes, but this form is being handled by a civicrm action ..
and civicrm takes care of form validation and escaping charaters etc within its form processing framework (which is different from drupal's form api)
lobo