ajax_include_subscribe.cgi - An AJAX'd subscription form
Put it in your, extensions directory (ala: cgi-bin/dada/extensions), chmod 755, visit it in your web browser.
This small extension script is an exampe of a Dada Mail subscription form with AJAX hooks. Highly customizable, it is meant to be used in one of two ways:
To add this form to your HTML page, just add a line that looks like this:
<script type="text/javascript" src="http://example.com/cgi-bin/dada/extensions/ajax_include_subscribe.cgi"></script>
You can also call it as a server side include, like this:
<!--#include virtual="/cgi-bin/dada/ajax_subscribe.cgi?mode=html" -->
Make sure to add the query string, mode=html
Not really a method, but you can view the HTML and Javascript produced by visiting the extension in your web browser, with the same query string you use for the Server Side Include:
http://example.com/cgi-bin/dada/ajax_subscribe.cgi
You could also try just copying the source that this script produces from the URL above, and paste it into a page/script/etc that you'd like.
Probably not the best idea, but I'll throw that idea for ya.
There's no configuration that you are required to do, but there's many things that you can do. We'll try to cover everything:
By default, this subscription form shows a popup menu containing every available list, so a visitor may select which list to subscribe to.
If you would like to have this form work for only one list, you may set the list short name in the $Plugin_Config-{Default_List} > variable:
$Plugin_Config->{Default_List} = 'mylistshortname';
If you've configured this variable incorrectly, you'll most likely receive an error in your web browser, so take care in setting it correctly.
If set to, 1, this extension will attempt to cache the default subscription form it creates. This could lighten the load on busy websites. Do note that Global Page Caching has to be turned on for this to work.
See Also:
Config.pm.html#_screen_cache__caching_html_screens
%Subscription_Descriptions holds the many possible messages that are displayed, when a successful request for a subscription was handled. The keys to the key/value pairs correspond to the various internal codes used by Dada Mail. See also:
MailingList_Subscribers.pm.html#subscription_check
The whole idea of having an AJAX'd subscription form is to not have to refresh the page and redirect your visitor to Dada Mail itslef when requesting a subscripiton.
If you would like a redirection to take place, all you need to do is list the internal key code into the @Subscription_Redirect_This array. The possible keys available are also the keys listed in %Subscription_Descriptions
%Unsubscription_Descriptions holds the many possible messages that are displayed, when a successful request for an unsubscription was handled. The keys to the key/value pairs correspond to the various internal codes used by Dada Mail. See also:
MailingList_Subscribers.pm.html#unsubscription_check
For a description of these various key/value pairs.
The whole idea of having an AJAX'd subscription form is to not have to refresh the page and redirect your visitor to Dada Mail itslef when requesting a subscripiton.
If you would like a redirection to take place for an unsubscription request, all you need to do is list the internal key code into the @Unsubscription_Redirect_This array. The possible keys available are also the keys listed in %Unsubscription_Descriptions
The %Loading hash contains a few variables you can set to customize the ``Loading...'' message displayed as this extension goes about its business with your request.
$JS_Code holds the Javascript template that's shown when you initially visit the form. It's written in the HTML::Template templating language.
$Form holds the HTML template that's shown when you initially visit the form. It's written in the HTML::Template templating language.
$Process_Screen holds the HTML template that's shown in the HTML element of the $Default_Screen that has an id of, resultdiv
See the Subscription Cookbook on an explanation on how the subscription code works:
COOKBOOK-subscriptions.pod.html
also see DADA::MailingList::Subscribers for the nitty-gritty stuff.
MailingList_Subscribers.pm.html
The AJAX'y stuff is created using CGI::Ajax:
http://search.cpan.org/~bct/CGI-Ajax/lib/CGI/Ajax.pm
The HTML templates are using a templating language called, HTML::Template:
http://search.cpan.org/~samtregar/HTML-Template/Template.pm
Yes!
See:
http://dadamailproject.com/cgi-bin/dada/extensions/ajax_include_subscribe.cgi
None, really.
Please, let me know if you find any bugs.
Justin Simoni
See: http://dadamailproject.com/contact
Copyright (c) 2006-2008 Justin Simoni All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.