Show All

Using parameters with database-driven documents

A parameter, as it relates to the Web, is a variable that is appended to the end of a URL pointing to a database-driven document. Both the parameter’s name and its value are included in the URL. For example, in the URL:

http://www.example.com/news/article.php?id=1124

the parameter is the string that follows the question mark. The word “id” is the parameter’s name, and 1124 is its value.

Parameters can be used in three different ways with database-driven documents created using the Database Wizard:

  • A parameter can determine the database record or records displayed in a block.
  • A parameter can provide the contents of an output elementIn a database-driven content block, an element that (usually) displays the contents of a single database field. Alternatively, an output element can display the value of a parameter passed to the document..
  • A parameter can provide the default valueThe initial contents of an input box, or the initial selection in an input control, when the document is opened in a browser. for an input elementA form field or form control in an input or modification block. An input element accepts user data or a user selection that will be inserted into a database..
Namo Web Editor icon reveal Using parameters with database driven documentsUsing a parameter to determine the record displayed in a block

Much of the power of database-driven Web documents lies in their ability to display different content, depending on a parameter that is appended to the URL that links to such a document. The same document on the Web server serves as a template for many different generated documents that the server sends to Web browsers.

For example, say you have a document named article.php, containing a detail block that displays one article in a database of news stories. A typical URL for this document might look like:

http://www.example.com/news/article.php?id=1124

The parameter (the part of the URL that follows the question mark) tells the server which article is being requested—in this case, the article whose ID number is 1124. Since the parameter’s value can vary, the same URL can be used to display many different articles by simply changing the value of the parameter.

To use a parameter to determine the record that is displayed in a block, you include a reference to it in the filter condition for the block. You can use a parameter in the filter condition of any kind of block except input blocks. (Since an input block does not retrieve a record from the database, it cannot make use of a parameter in this way.)

To include a parameter in a filter condition, click the button next to the Filter box and select the parameter. For more information about entering filter conditions, see “Filtering and sorting database records“.

Namo Web Editor icon reveal Using parameters with database driven documentsUsing a parameter to provide the contents of an output element

Usually, an output elementIn a database-driven content block, an element that (usually) displays the contents of a single database field. Alternatively, an output element can display the value of a parameter passed to the document. is used to display the contents of a database field. However, you can make an output element display the value of a parameter instead. To specify a parameter for an output element, click the button next to the Database field box in the Output Element Properties dialog box and select a parameter. For more information, see “Adding an output element“.

Namo Web Editor icon reveal Using parameters with database driven documentsUsing a parameter to provide the default value for an input element

Any input elementA form field or form control in an input or modification block. An input element accepts user data or a user selection that will be inserted into a database. can be assigned a default value, which determines the initial contents or selection of the input element when the document is opened in a browser. You can specify a fixed default value, such as the string “John Smith” or the number 42, or you can specify that the default value be equal to the value of a parameter. To set a default value to the value of a parameter, click the button next to the Default value box in properties dialog box for the input element and select a parameter. For more information, see “Modifying the properties of an input box“.

Namo Web Editor icon reveal Using parameters with database driven documentsParameters in generated hyperlinks

Although you can create an ordinary (static) link to a dynamic document and include a parameter in the link, a much more powerful way to use parameters is to have the Web server generate hyperlinks in another dynamic document. This can be done using a hyperlink output element in an output block.

For example, say you have a list block that displays a list of headlines from a database of news stories. It might look something like this:

Man Dies in Bizarre Bowling Accident

“Gangs of New York” Royally Snubbed at Oscars

Red Sox Win World Series (of Line Dancing)

Star Trek Fan Defends Vulcan Mating Ritual

Scientist Says Smoking Reduces Risk of Jogging

[ 1 2 ] [ >&g
t;
]

In this list block, each news headline is a hyperlink to another dynamic document that displays the whole article. The hyperlinks are generated by the Web server from a base URL you specify—for example, /news/article.php. The server appends to the base URL a parameter whose name is the same for each link, but whose value depends on the value of a field in the individual database record.

For more information about hyperlink output elements, see “Adding a hyperlink output element“.

In this section

Registering a parameter

Related topics

Filtering and sorting database records

Adding a hyperlink output element

Using parameters with database-driven documents