Positioning a code block
When you create code blocks using
the Server Behavior Builder, you must specify where to insert them
in the page’s HTML code.
For example, if you insert a code block above the opening <html> tag,
you must then specify the code block’s position relative to other
tags, scripts, and server behaviors in that section of the page’s
HTML code. Typical examples include positioning a behavior either
before or after any recordset queries that might also exist in the
page code above the opening <html> tag.
When you select a positioning option from the Insert Code pop‑up
menu, the options available in the Relative Position pop‑up menu
change to provide relevant options for that part of the page. For
example, if you select Above The <html> Tag
In The Insert Code pop‑up menu, the positioning options available in
the Relative Position pop‑up menu reflect choices relevant for that
part of the page.
The following table shows the code block insert options, and
the relative positioning options available for each:
Insert Code options
|
Relative position options
|
Above the <html> Tag
|
At the beginning of the file
Just before the recordsets
Just after the recordsets
Just above the <html> tag
Custom position
|
Below the </html> Tag
|
Before the end of the file
Before the recordset close
After the recordset close
After the </html> tag
Custom position
|
Relative to a Specific Tag
|
Select a tag from the Tag pop‑up menu, and
then choose from the tag positioning options.
|
Relative to the Selection
|
Before the selection
After the selection
Replace
the selection
Wrap the selection
|
To specify a custom position, you must assign a weight to
the code block. Use the Custom Position option when you need to
insert more than one code block in a particular order. For example,
to insert an ordered series of three code blocks after the code
blocks that open recordsets, you would enter a weight of 60 for
the first block, 65 for the second, and 70 for the third.
By default, Dreamweaver assigns a weight
of 50 to all recordset-opening code blocks inserted above the <html> tag.
If the weight of two or more blocks match, Dreamweaver randomly
sets the order among the blocks.
Position a code block (general instructions)
- Using the Server Behavior Builder, write
a code block.
- In the Server Behavior Builder dialog box, select a position
in which to insert the code block from the Insert Code pop‑up menu.
- In the Server Behavior Builder dialog box, select a position
relative to that which you selected in the Insert Code pop‑up menu.
- If you complete the authoring of the code block, click
OK.
The server behavior is listed in the Server Behaviors panel
(Window > Server Behavior); click the Plus (+) button
to view the server behavior.
- Test the server behavior and ensure that it functions
properly.
Position a code block relative to another tag on the page
- In the Insert Code pop‑up menu, select
Relative To A Specific Tag.
- In the Tag box, enter the tag or select one from the
pop‑up menu.
If you enter a tag, don’t include the angled brackets (<>).
- Specify a location relative to the tag by choosing an
option in the Relative Position pop‑up menu.
Position a code block relative to a tag selected by the page designer
- In the Insert Code pop‑up menu, select
Relative To The Selection.
- Specify a location relative to the selection by choosing
an option in the Relative Position pop‑up menu.
You can insert your code block just before or just after
the selection. You can also replace the selection with your code
block, or you can wrap the code block around the selection.
To
wrap the code block around a selection, the selection must consist
of an opening and closing tag with nothing in between, as follows:
<CFIF Day=”Monday”></CFIF>
Insert
the opening tag piece of the code block before the selection’s opening
tag and the closing tag piece of the code block after the selection’s
closing tag.