You are on page 1of 4

Posting an Article in the Blog

For publishing articles to your blog, you have created the post.php page, which contains a record
insertion form.
1.
2.
3.
4.
5.

Open the post.php page.


Apply the blgtemplate to it.
In the title field of the Document bar, enter Blog: Post Article as the title of the page.
Click inside the main editable region.
Click the Application tab from the Insert bar and select Record Insertion Form Wizard from the
Insert Record button bar.
6. Configure the Record Insertion Form as listed below and shown in Figure 23.

Figure 23. The Record Insertion form


(+) View larger

Use the defined database connection.


Select the table that you want the record inserted into: blg_article_art
Select the page to redirect users to after the insertion: index.php.
You need to remove the id_art field, because this is auto incremented each time a record is
inserted in the table. To remove a field, select it and click the Minus (-) button.
Also, remove the idtop_art field. Select the topic from a pop-up menu that you will create
later.
For each of the remaining fields, enter a label, as seen in the screen shot.
Change the description_art and text_art fields to display as text areas, because you need
to insert a larger amount of text into these fields.
Change the date_art field to display as a hidden field, and set its default value to:
<?php echo date('Y-m-d H:i:s'); ?>

This way, you don't have to manually specify the value of the date_art field. The server will
automatically populate it with the current date and time.

Note: The date( ) function is a special PHP function that returns the current local date and time, in the
specified format. The echo function is another PHP function that outputs its parametersin this case,
the results of the date function.

Click OK to exit the Record Insertion Wizard and insert the form on the page.

Figure 24 shows how the form should appear in Design view:

Figure 24. The record insertion form in Design View


(+) View larger
There's only one problem with this form: you cannot select the topic to which the article belongs. But
why then have I removed the idtop_art field from the form? Wasn't that necessary to specify the
topic. Indeed, idtop_art is used to identify the topic to which a certain article belongs. However, this
is only a numeric field and it would be a daunting task to guess what number a certain topic has and
then write that number in a text field. Instead, you should be able to select the topic name from a
dynamic pop-up menu.
A dynamic pop-up menu displays a set of record fields from a recordset and allows you to select one.
Should the database be modified, the dynamic menu changes accordingly, without requiring you to
change the menu entries manually.
Create a simple recordset called rsMenu in the post.php page, just as you have done for the
Dreamweaver template. The rsMenu recordset must contain all the topics from the blg_topic_top
table.
Create the dynamic menu using these steps.
1. Insert a new row in the form table, right after the Article title field.
2. Write the label Topic in the left cell of the new row.
3. In the right cell, insert a pop-up menu by clicking the List/Menu button from the Forms tab of
the Insert bar.
4. Select the menu and label it idtop_art in the Property inspector.
5. Click the Dynamic button from the Property inspector and configure the Dynamic Menu dialog
box as shown in Figure 25.

o
o

You will use the options from the rsMenu recordset.


The submitted value is id_top, but the actual entries in the pop-up menu are the names
of the topics specified by title_top.

Figure 25. The Dynamic List/Menu dialog box


6. Click OK.
Next, update your form to include the newly created dynamic menu:
1. Go to the Server Behaviors tab in the Application panel.
2. Double-click the Insert Record server behavior.
3. In the list of columns, you can see that the idart_top does not get any value. Select this
column and set its value to that of the idart_top form field.

Figure 26. The Insert Record dialog box


(+) View larger
4. Click OK.
The insert form is now ready for action. Preview it in the browser by pressing F12 and see how it
works.

Figure 27. The insert article form


(+) View larger
Your application is ready. You have set up a basic blog, where you can post articles and visitors can
read them. But it doesn't look very appealing, does it? You need to add some CSS touch to your blog to
make it more lively. In the next section, you will learn how to do that.

You might also like