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

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.

主站蜘蛛池模板: 邯郸市| 西城区| 福州市| 阳城县| 霍林郭勒市| 大新县| 永善县| 荃湾区| 吴忠市| 韩城市| 昆明市| 临清市| 邵阳县| 镇雄县| 万年县| 营山县| 广元市| 平乐县| 灵山县| 庐江县| 墨江| 拜城县| 佳木斯市| 富宁县| 菏泽市| 永川市| 尉犁县| 竹山县| 阳曲县| 安阳市| 肇源县| 阿合奇县| 金沙县| 翼城县| 鸡西市| 大丰市| 吉水县| 黑水县| 阿拉尔市| 抚州市| 波密县|