Putting a subscribe form on other applications

You may not always want to direct your customers to the phpList subscribe page, but may want (for example) to embed the subscribe form within an existing page on your blog.

Note

This is covered in more detail in the phpList wiki at http://docs.phplist.com/CustomSubscribeForm.

Generating HTML code for the subscribe form

Create your subscribe form within phpList, customizing it to suit your needs. Once you're satisfied with the way it looks, view the subscribe form as a normal user (that is, not as a logged-in administrator), and use your browser to view the source code. (Generally, right-clicking brings up a variant of a view source option in your browser).

Look in the source code for the following text:

<form method=post name="subscribeform">

This is the beginning of the HTML code for the subscribe form. Copy everything from the first "<form to the ending</form>" tag and paste it into a text editor.

Customizing HTML code

Now we will customize this code to make it work as a generic form, which can then be embedded into an unrelated HTML page.

Changing the form action

Change the following opening form tag from this:

<form method=post name="subscribeform">

To this, if this is the default subscribe page:

<form method=post action="http://your-phplist-site/?p=subscribe" name="subscribeform">

Or to this, if this is not the default subscribe page, where x is the ID of the subscribe page:

<form method=post action="http://your-phplist-site/?p=subscribe&id=x" name="subscribeform">

Removing the JavaScript

Unless you manually copy the phpList JavaScript functions across to the website where you'll be embedding the form, you will probably want to remove anything in the form code between the<script> tags since, at best, these will be rendered ineffective and, at worst, will display errors.

Optional pop-up confirmation

If you've embedded the subscribe form into another website, you may not want your reader to be redirected off your website and to the phpList "thank you" page. If we add a "target" to our form tag, our browser will bring up the "thank you" page in a new, pop-up window, leaving the original browser window unchanged.

Edit the HTML code and change the opening form tag from this:

<form method=post action="http://your-phplist-site/?p=subscribe" name="subscribeform">

To this:

<form method="post" action="http://your-phplist-site/?p=subscribe" name="subscribeform" target="windowName" onsubmit="window.open('', this.target, 'dialog,modal,scrollbars=no,resizable=no,width=550,height=300,left=0,top=0'),">

Removing the subscribe form button

You may want to further alter the form code in your HTML editor and perhaps replace the subscribe form button with an image. The form won't work without the original button though, so you can hide it by replacing:

<input type=submit name="subscribe" value="Subscribe to the Selected Mailinglists" onClick="return checkform();">

With:

<input type="hidden" name="subscribe" value="yes">

Tip

Embedding code into other applications

Having customized the HTML form code, you can now insert it into any HTML page to provide a subscription form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.142.85