Building a Master Page


A master page displays a list of records with links to detail pages that provide additional information about a single record. In the following tasks, you'll build a master page by creating a dynamic page and defining a recordset that includes a filter and a sort, and then inserting a dynamic table so that you can include multiple records in the list.

The following tasks use ColdFusion, but you can also use either ASP or PHP.

To create a master page:

1.

Open a new ColdFusion page in Dreamweaver (File > New > Dynamic page > ColdFusion). Save the page as master_cafe.cfm.

2.

In the Application panel group, click the Bindings tab to access the Bindings panel.

3.

Click the plus button, and from the menu choose Recordset (Query) (Figure 10.1).

Figure 10.1. To open the Recordset dialog, on the Bindings panel click the plus button and choose Recordset (Query).


The Recordset dialog appears (Figure 10.2).

Figure 10.2. Create a ColdFusion recordset for the master page in the Recordset dialog.


4.

In the Name field, enter a name for the recordset. Choose a name that will help you to identify the recordset later.

For this exercise we're using the cafe-townsend database, so we named our recordset cafe.

5.

In the Data Source drop-down list, select the name for your connection to the sample cafetownsend database. Our connection is named connTownsend.

If you're using ASP or PHP, this list will be called Connection instead of Data Source.

6.

In the User Name and Password fields, enter a user name and a password if required by your database administrator. Otherwise, leave these two fields blank.

7.

From the Table drop-down list, choose LOCATIONS.

8.

In the Columns section, choose the Selected radio button, and then select the CODE, LOCATION_NAME, CITY, and STATE_COUNTRY fields that appear in the box below the radio button.

You've now added these four fields from the LOCATIONS table to your recordset. You'll display these four fields on your master page when you add a dynamic table in the task "To insert a dynamic table on the master page," later in this section.

9.

Click the Test button to see the contents of the recordset.

The Test SQL Statement window appears with the contents of the CODE, LOCATION_NAME, CITY, and STATE_COUNTRY fields (Figure 10.3). Click OK to return to the Recordset dialog.

Figure 10.3. View the cafe recordset in the Test SQL Statement window.


10.

Click OK in the Recordset dialog to save the recordset and close the dialog. Save the page.

The recordset name appears on the Bindings panel (Figure 10.4).

Figure 10.4. The name of the new recordset (cafe) appears on the Bindings panel.


In the next task, you'll add a filter to the recordset to include only European locations and sort the records in ascending order alphabetically by country name.

To filter and sort the master page recordset:

1.

Open master_cafe.cfm or the dynamic page you created in the previous task.

2.

In the Application panel group, click the Bindings tab to access the Bindings panel.

3.

Double-click the cafe recordset to open the Recordset dialog (Figure 10.2).

4.

In the Filter section, choose REGION_ID from the drop-down list (Figure 10.5). This menu includes the name of every field in the LOCATIONS table. Then, from the drop-down list on the right, choose the equals sign (=).

Figure 10.5. Use Entered Value in the Filter section to set a specific value that a field must have to be included in the recordset. In this case, the REGION_ID must be equal to 3.


This is the first step to creating the filter for the recordset data. You specify which field should be used (REGION_ID) and how the data in the field should be evaluated. In this case, we want the REGION_ID to be equal to a certain value, so we use the equals sign (=). You'll finish creating the filter in the next step.

5.

From the drop-down list in the lower left of the Filter section, choose Entered Value. In the field to the right enter 3.

This is the second step to creating the filter. You specify that you want to include records where the value for REGION_ID is equal to 3. "Entered value" means that you are specifying a static value, in this case 3. The REGION_ID field in the LOCATIONS table contains a numeric value for each geographic region. A value of 3 is used for locations in Europe.

6.

In the Sort section, choose STATE_COUNTRY from the first drop-down list and Ascending from the second dropdown list (Figure 10.6).

Figure 10.6. In the Sort section, choose a field to use for sorting the data, and then choose whether to sort the data in ascending or descending order.


The recordset is now sorted in alphabetical order by the data in the STATE_COUNTRY field.

7.

Click the Test button.

The Test SQL Statement window appears, displaying a list of CafeTownsend locations in Europe, listed alphabetically by country (Figure 10.7).

Figure 10.7. In the Test SQL Statement window, view all European locations for cafetownsend in ascending order by country.


8.

Click OK to close the Test SQL Statement window, and then click OK in the Recordset dialog to save the recordset and close the dialog.

9.

Save the page.

In the next task, you'll add a dynamic table with a repeat region to display the master page list.

Tip

  • You don't have to add a field to your recordset in order to use it in a filter or a sort; you can use any field in the same database table. The REGION_ID field is not one of the three fields we chose for the master page recordset, but we used it for the filter in Step 4.


To insert a dynamic table on the master page:

1.

Open master_cafe.cfm or the dynamic page you used in the previous task.

2.

Choose Insert > Application Objects > Dynamic Data > Dynamic Table to insert a dynamic table. The Dynamic Table dialog appears (Figure 10.8).

Figure 10.8. Choose a recordset, number of records per page, and table settings in the Dynamic Table dialog.


3.

From the Recordset drop-down list, choose cafe.

4.

In the Show section, select the Records at a Time radio button. The default number of records that will be shown at one time is 10.

The Repeat Region server behavior that's included in the Dynamic Table application object dynamically adds a row for every record in the recordset, up to the number of rows that you set in the Show field. If more rows are needed to display all the records, an additional page is created and recordset navigation links are automatically added.

5.

In the Border, Cell Padding, and Cell Spacing fields, enter values for the number of pixels for the width of the table border, the padding between the outer border of a cell and its contents, and the space between the cells, respectively. You can also use the supplied default values, shown in Figure 10.8. Click OK to close the dialog and insert the table.

The Dynamic Table application object inserts HTML table code, adds column headings to the first row of table cells using the recordset field names, adds placeholders for the recordset fields to the second row of table cells, and adds a Repeat Region server behavior to display multiple records in the table.

6.

The table now appears in Design view (Figure 10.9).

Figure 10.9. A dynamic table includes placeholders for dynamic text fields.


7.

Save the page.

The next part of the process involves adding links and URL parameters to connect the master page to the detail page.

Tip

  • Edit the names of the column headings to make the table easier for your page visitors to use (Figure 10.10). You can change any design features of the table, such as background color, size, or border type.

    Figure 10.10. You can change any features of the table, including the column headers or design features, such as the size or background color.





Macromedia Dreamweaver 8 Advanced for Windows and Macintosh. Visual Quickpro Guide
Macromedia Dreamweaver 8 Advanced for Windows and Macintosh: Visual QuickPro Guide
ISBN: 0321384024
EAN: 2147483647
Year: 2004
Pages: 129
Authors: Lucinda Dykes

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net