Adding Dynamic Text


You can add dynamic text to any page or replace existing static text with dynamic text. Existing page formatting or text formatting, such as an HTML tag or CSS style, will be applied to the dynamic text, or you can add other formatting instructions for the dynamic text.

You can also use Dreamweaver's predefined data formats, such as date or currency formats, to format dynamic content. The available data formats vary according to the data type of the selection.

To add dynamic text:

1.

Open the dynamictext.php page that you created in the preceding task.

2.

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

A list of recordset names displays (Figure 7.5).

Figure 7.5. The recordset names are displayed on the Bindings panel.


If no names display, click the plus button to add a recordset. (See Chapter 6 for more details on defining recordsets.)

3.

In the recordset list, click the plus button to the left of a recordset name to display the recordset fields.

4.

In the Document window in Design view, select text on the page or place the insertion point where you want to insert dynamic text (Figure 7.6).

Figure 7.6. In the Document window, place the insertion point where you want to insert dynamic text.


5.

On the Bindings panel, select a field name and then click the Insert button at the bottom of the panel.

A placeholder appears in the Document window for the dynamic-text item. The placeholder for a recordset is formatted as recordsetName.fieldName, with curly brackets ({ }) on either side (Figure 7.7).

Figure 7.7. A placeholder with the recordset name and field name is inserted in Design view whenever you add dynamic content to a page.


6.

Save the page, and then from the main menu, choose File > Preview in Browser to preview the page.

The placeholder is replaced with data from the first row of the specified field (Figure 7.8).

Figure 7.8. When you preview a page with dynamic content in a browser, the placeholder is replaced by data from the first record in the recordset.


Tip

  • When you add dynamic content to a Dreamweaver page, only data from the first record in the recordset is displayed. For example, there are 23 locations in the Locations recordset, but only the first location is added to the page. To view content from multiple records on the same page, you can add a Repeat Region behavior from the Server Behaviors panel. For more information on using the Repeat Region behavior and other server behaviors, see Chapter 9.


To format dynamic text:

1.

Open the dynamictext.php page you saved in Step 6 of the preceding task.

2.

In the Document window in Design view, select a placeholder. To add HTML text formatting or CSS styles to the dynamic text, do one of the following:

  • From the Text Insert bar, which you can access by choosing View > Toolbars > Insert > Text, choose a text-formatting element to apply it to the selection (Figure 7.9).

    Figure 7.9. To add HTML text formatting to dynamic text, select the placeholder for the dynamic text and choose a formatting type from the Text Insert bar.


  • In the CSS panel group, click the CSS Styles tab to access the CSS Styles panel (Figure 7.10). Click the plus button at the bottom of the panel to create a new style; or if a style sheet is attached to the page, right-click a style name on the panel, and from the contextual menu, choose Apply.

    Figure 7.10. You can use the CSS Styles panel to add CSS formatting to dynamic text.


  • In the Property inspector, choose text formatting and/or styles to apply to the selection (Figure 7.11).

    Figure 7.11. In the Property inspector, you can add HTML text formatting or CSS styles to dynamic text.


3.

Save the page, and then from the main menu choose File > Preview in Browser to preview the formatted data (Figure 7.12).

Figure 7.12. When you preview a page with formatted dynamic text, the placeholder is replaced by formatted text data.


To format dynamic text using predefined data formats:

1.

Open the dynamictext.php page.

2.

In the Document window in Design view, select a placeholder.

3.

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

The field name in the Bindings panel is selected when you select the placeholder in Design view.

4.

Click the downward-pointing arrow next to the selected field name (Figure 7.13). From the pop-up menu, select a data format to apply to the selection.

Figure 7.13. Apply one of Dreamweaver's data formats to your dynamic text by clicking the downward-pointing arrow next to the field name on the Bindings panel and selecting a data format from the pop-up menu.





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

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