In this section, you create the navigation menu of the blog template. This contains all the topics, which are dynamically extracted from the database. For that, you need:
Fill in the MySQL connection dialog box as shown in Figure 8. You must provide your own MySQL server, username, and password.
Note: In a production environment, do not use the root password for your web applications.
If you are not sure how to connect to the database server or are getting error messages when testing the connection, ask the system administrator or your web host for the proper access information. Use the Select button to quickly locate the blog database. You can test the connection using the Test button.
The connection displays in the Databases panel. Click the plus (+) icon to expand it. As shown in Figure 9, you can see the table organization of the blg_blog database.
Note: Dreamweaver automatically generates the PHP/MySQL code for connecting to the database and stores this information in a special file (connBlog.php) in the Connections folder, which is automatically created inside the site root folder.
Next, you need to extract the information you want to use from the database. For this, you create a recordset:
Fill in the Recordset dialog box as shown in Figure 10.
Dreamweaver displays a message window, warning you that subsequent changes to the code that was generated will not copy to documents based on the template. That is why it is important to generate the recordset correctly the first time. Click OK to dismiss the warning dialog box.
(+) View larger
The recordset displays in the Bindings panel. Click the plus (+) icon to expand it. it.
The point-and-click approach of Dreamweaver makes it very easy to connect to a database and generate a recordset. You do not have to write any PHP or MySQL code, just fill in two dialog boxes and you're done.
Getting back to the navigation menu, you will learn how to display the data from the recordset you have created.
Fill in the Dynamic Table dialog box as shown in Figure 13.
Display all the topics, because users must be able to navigate through all of them.
Insert the table in the left cell. However, you only need the name of each topic for the menu, so you should delete the id_top and the description_top columns; just select the table colums and press the Delete key. Next, change the title_top column heading with a human-readable one, such as Topics.
Currently, the menu entries have no links associated to them. Each menu entry should lead to the topic.php page and pass it an URL parameter, which takes corresponding id of the topic as the value. To create the link:
character, because you need to use
the relative path to the file. The URL should be topic.php.Click the Parameters button next to the URL text box. Dreamweaver opens a dialog box, where you should define the URL parameter associated to this link.
Before finishing the template, define which regions can be further edited and which can not. Your blog template will have only one editable region: the main area where the articles display. To make this region editable:
Save the template file. Figure 14 shows how the template page looks so far in Dreamweaver Design view.
|