Create site content

In this section of the tutorial you will build the site's main page (mail) which displays in a dynamic table article titles and descriptions, and which must be sent by e-mail to recipients retrieved by a recordset.

As for the index and thankyou pages, if you use the files provided in the zip package, they already have content added.

If creating your own pages, follow the next steps to add the same content:

  1. In the index page, type Send article list. Select the text and right-click on it. From the pop-up menu select the Make link option. In the dialog box that opens select the mail file and click on OK. Save the page and upload it to the server.

  2. For the thankyou.htm page, simply add some text (e.g. The mail message has been sent to all selected addresses.). Optionally, you can also add a link to the site index, to make re-sending the messages easier.

Next you will create the site's most important page: mail, which will contain a table with dynamic values, which will send to a list of recipients.

To create this page, follow the next steps:

  1. Open the mail page in Dreamweaver.

  2. First add a recordset that will retrieve all articles from the database. To add a new recordset, click the Plus (+) button from the Bindings tab, and from the pop-up menu select the Recordset (Query) option. The new recordset dialog box will open.

  3. In the dialog box enter the new recordset's name (rsArticles), select the database connection defined at the beginning of this tutorial, and the page_pag table:


     

  4. Next add a Dynamic table on the page that will display the data. To add a dynamic table, click its icon in the Application tab of the Insert panel. In the dialog box that opens, select the rsArticles recordset as source, and set it to display all records.


     

  5. From the table added to the page, remove all columns except the title_pag and description_pag. For the remaining fields, change the header to Title and Description. Also set the columns to be headers (check the header option in the property inspector for both cells):


     

  6. Save the page and preview it in the browser to make sure the table really displays the correct articles.


     

  7. The same list should be displayed in the index page as well, so that you know what the mail message will look like. To achieve this, open the index page in Dreamweaver (if not already opened) and repeat steps 2 through 6. Then save and upload the index to the server.

  8. Now create the recordset that will retrieve the recipients. To add the recordset click on the Plus (+) button of the Bindings tab, and select Recordset (Query). In the dialog box that opens, enter the recordset name (rsMail), select the database connection defined at the beginning of this tutorial and the user_usr table:


     

  9. Next select the entire table on page (either drag and drop around it, or click the <table> tag in the tag inspector:


     

  10. Apply the Send Page Section by E-mail server behavior. To access the server behavior, go to the Server Behaviors tab > + > MX Kollection > Send E-mail. Configure the dialog box as follows:

  11. At this point, if you save all site pages, and upload them to the server, you can click on the link situated in the site's index. But only the first address retrieved by the recordset will receive the message, and not all. This happens because the simple use of the field mark-up in the interface does not loop through the recordset entries. To implement this, you will have to manually enter some code.

  12. In Dreamweaver, switch to code view: View > Code. Locate the code section that initializes the tNG_EmailPageSection object.

  13. The line that establishes the recipient is the one containing the call to the setTo function (eg. $sectemailObj->setTo("{rsMail.email_usr}");). Cut this line from the page, as it will have to be moved lower in the code.


     

  14. Also locate the code line that executes the object (similar to sectemailObj->Execute() ). Before this line paste the setTo code you've cut before. Now you should have the two lines together.


     

  15. Next you have to enter the code that will loop through the recordset. The two lines of code shown in the image above must be inside the loop. To implement the recordset looping, you must type the following code:

  16. For PHP, the final code looks like the following: (for the other server models, the code resembles, with only syntax differences):


     

  17. Once the recordset loop code is added, you can save the page and upload it to the server. If you access the mail page, it will send the article table to all users in the recordset. Here's a sample image taken from the mail Inbox: