Creating code blocks – Adobe Dreamweaver CC 2014 v.13 User Manual

Page 548

Advertising
background image

To the top

2. From the Document Type pop-up menu, select the document type that you are developing the server behavior for.

3. In the Name box, enter a name for the server behavior.

4. (Optional) To copy an existing server behavior to add to the behavior you are creating, select the Copy Existing Server Behavior option, and

then select the server behavior in the Behavior to Copy pop-up menu. Click OK.

The Server Behavior Builder dialog box is displayed.

5. To add a new code block, click the Plus (+) button, enter a name for the code block, and click OK.

The name you enter appears in the Server Behavior Builder, with the appropriate scripting tags visible in the Code block box.

6. In the Code Block box, enter the run-time code necessary to implement the server behavior.

Note: When entering code in the Code Block box, you can only insert a single tag or code block for each named code block (for example,
myBehavior_block1, myBehavior_block2, myBehavior_blockn, etc.). If you have to enter multiple tags or code blocks, create an individual
code block for each one. You can also copy and paste code from other pages.

7. Place the insertion point in the code block where you’d like to insert the parameter, or select a string to replace with a parameter.

8. Click the Insert Parameters in Code Block button.

9. Enter a name for the parameter in the Parameter Name box (for example, Session), and click OK.

The parameter is inserted into the code block at the location where you placed the insertion point prior to defining the parameter. If you
selected a string, every instance of the selected string in the code block is replaced with a parameter marker (for example,
@@Session@@).

10. Select an option from the Insert Code pop-up menu specifying where to embed the code blocks.

11. (Optional) To specify additional information about the server behavior, click the Advanced button.

12. To create more code blocks, repeat steps 5 through 11.

13. If the server behavior requires that parameters be supplied to it, you must create a dialog box that accepts parameters from the person

applying the behavior. See the link below.

14. After you perform the required steps to create the server behavior, click OK.

The Server Behaviors panel lists the server behavior.

15. Test the server behavior and ensure that it functions properly.

Advanced options

After you specify the source code and insert location for each code block, the server behavior is completely defined. In most cases, you don’t need
to specify any additional information.

If you are an advanced user, you can set any of the following options:

Identifier Specifies whether the code block should be treated as an identifier.

By default, every code block is an identifier. If Dreamweaver finds an identifier code block anywhere in a document, it lists the behavior in the
Server Behaviors panel. Use the Identifier option to specify whether the code block should be treated as an identifier.

At least one of the server behavior’s code blocks must be an identifier. A code block should not be an identifier if one of the following conditions
applies: the same code block is used by some other server behavior; or the code block is so simple that it might occur naturally on the page.

Server Behavior Title Specifies the title of the behavior in the Server Behaviors panel.

When the page designer clicks the Plus (+) button on the Server Behaviors panel, the new server behavior’s title will appear in the pop-up menu.
When a designer applies an instance of a server behavior to a document, the behavior appears in the list of applied behaviors in the Server
Behaviors panel. Use the Server Behavior Title box to specify the contents of the Plus (+) pop-up menu and the list of applied behaviors.

The initial value in the box is the name you supplied in the New Server Behavior dialog box. As parameters are defined, the name is automatically
updated so that the parameters appear inside parentheses after the server behavior name.

Set Session Variable (@@Name@@, @@Value@@)

If the user accepts the default value, everything before the parentheses appears in the Plus (+) pop-up menu (for example, Set Session Variable).
The name plus the parameters will appear in the list of applied behaviors—for example, Set Session Variable ("abcd", "5").

Code Block to Select Specifies what code block is selected when the user selects the behavior in the Server Behaviors panel.

When you apply a server behavior, one of the code blocks within the behavior is designated the “code block to select.” If you apply the server
behavior and then select the behavior in the Server Behaviors panel, the designated block is selected in the Document window. By default,
Dreamweaver selects the first code block that is not above the html tag. If all the code blocks are above the html tag, then the first one is
selected. Advanced users can specify which code block is the selected one.

Creating code blocks

The code blocks you create in the Server Behavior Builder are encapsulated in a server behavior that appears in the Server Behaviors panel. The
code can be any valid run-time code for the specified server model. For example, if you choose ColdFusion as the document type for your custom

541

Advertising
This manual is related to the following products: