AJAXed Subscription Form

- NAME
- USAGE
- DESCRIPTION

- As a Javascript Library
- As a Server Side Include
- By Itself
- By Copying the HTML/Javascript

- CONFIGURATION

- $Plugin_Config->{Default_List}
- $Cache_Subscribe_Form (currently, Disabled)
- %Subscription_Descriptions
- @Subscription_Redirect_This
- %Unsubscription_Descriptions
- @Unsubscription_Redirect_This
- %Loading
- $JS_Code
- $Form
- $Process_Screen

- SEE ALSO

- Dada Mail Docs
- CPAN Perl Modules

- DEMO
- DIAGNOSTICS
- CONFIGURATION AND ENVIRONMENT
- DEPENDENCIES
- INCOMPATIBILITIES
- BUGS AND LIMITATIONS
- AUTHOR
- LICENCE AND COPYRIGHT

# NAME

ajax_include_subscribe.cgi - An AJAX'd subscription form

# USAGE

- Use it like a cgi script.

  Put it in your, extensions directory (ala: cgi-bin/dada/extensions), chmod 755, visit it in your web browser.

# DESCRIPTION

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:

## As a Javascript Library

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>

## As a Server Side Include

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`

## By Itself

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

## By Copying the HTML/Javascript

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.

# CONFIGURATION

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:

## $Plugin_Config->{Default_List}

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.

## $Cache_Subscribe_Form (currently, Disabled)

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

%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

## @Subscription_Redirect_This

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

%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.

## @Unsubscription_Redirect_This

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

## %Loading

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

$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

$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

$Process_Screen holds the HTML template that's shown in the HTML element of the $Default_Screen that has an id of, resultdiv

# SEE ALSO

## Dada Mail Docs

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

## CPAN Perl Modules

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

# DEMO

Yes!

See:

http://dadamailproject.com/cgi-bin/dada/extensions/ajax_include_subscribe.cgi

# DIAGNOSTICS

None, really.

# CONFIGURATION AND ENVIRONMENT

# DEPENDENCIES

# INCOMPATIBILITIES

# BUGS AND LIMITATIONS

Please, let me know if you find any bugs.

# AUTHOR

Justin Simoni

See: http://dadamailproject.com/contact

# LICENCE AND COPYRIGHT

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.