官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 巩留县| 镶黄旗| 高要市| 达拉特旗| 原平市| 佳木斯市| 安乡县| 兴文县| 上杭县| 东港市| 科尔| 城固县| 苍梧县| 宿迁市| 娱乐| 广宁县| 马鞍山市| 平顺县| 锦屏县| 色达县| 汕尾市| 安平县| 台南市| 金阳县| 安康市| 海盐县| 中江县| 嘉义县| 邹城市| 天镇县| 白城市| 临桂县| 曲水县| 南郑县| 淅川县| 武功县| 茂名市| 余干县| 麻城市| 苍梧县| 宁都县|