Newscoop 3 Cookbook

General form elements and functions

Form Parameters

"formparameters" prints the runtime environment parameters in HTML form format. It prints only data context parameters and can be used to create links.

Syntax:

{{ formparameters [options="<options_list>"] }}
  • <options_list> =
    • <option>
    • <option> <options_list>
  • <option> =
    • fromStart
    • articleComment

Filters:

  • fromstart: prints the parameters received at the start of the template, not the current ones (useful when building site maps)
  • articleComment: inserts the article comment identifier in the parameters list; if no article comment was defined in the template environment, no parameter is inserted. This attribute is needed if you want to pass the current comment id to another page for display purposes.

Option Input Fields

Purpose:

Generate an option input field; these fields are used in forms to allow the reader to enter data. These must be used in conjunction with the form statements.

Syntax:

{{ camp_select object="<object_name>"
               attribute="<attribute_name>"
               [html_code="<HTML_code>"] }}

If the html_code parameter was set, the HTML code will be inserted inside the input field.

Example:

{{ camp_select object="user"
               attribute="country"
               html_code="id=\"countryId\"" }}

The following code will output a pop-up list of available countries:

<select name="f_user_country" id="countryId">
...
</select>

Text Input Fields

Purpose:

Generate an input text field; these fields are used in forms to allow the reader to enter data. These must be used in conjunction with the form statements.

Syntax:

{{ camp_edit object="<object_name>"
             attribute="<attribute_name>"
             [html_code="<HTML_code>"]
             [size ="<field_length>"]
             [columns="<max_columns>"]
             [rows="<max_rows>"] }}

For text input fields, if the size parameter was set, the input field size will be set to that value. For text box fields, if the columns/rows parameter was set, the box will have the given number of columns/rows.

Note: columns and rows parameters were implemented starting with Newscoop version 3.2.2.

If the html_code parameter was set, the HTML code will be inserted inside the input field. For example, the following code:

{{ camp_edit object="user"
             attribute="name"
             html_code="id=\"userNameInput\"" }}

will output:

<input type="text" name="f_user_name" size="50" maxlength="255" id="userNameInput">