Campsite

Forms

In this chapter:
  • Form: Login
  • Form: Search
  • Form: Comment
  • Form: User
  • Form: Subscription
  • Form Parameters
  • Text Input Fields
  • Edit Login
  • Edit Search
  • Edit Comment
  • Edit CAPTCHA
  • Edit User
  • Edit Subscription
  • Option Input Fields
  • Select Login
  • Select Search
  • Select User
  • Select Subscription
  • CAPTCHA ImageLink


Form: Login

Purpose:

Generate the form and data fields for logging in a user.

Syntax:

{{ login_form [template="<template_name>"] submit_button="<button_name>"
              [html_code="<html_code>"]
              [button_html_code="<html_code>"] }}
<list_of_instructions>
{{ /login_form }}
  • <template_name> is the name of the next template to be requested from login form.
  • <button_name> is the name of the button for submitting the form.
  • html_code: you can insert whatever HTML code you want in the <form> statement; e.g.: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; e.g.: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

Constraints:

Can not be used inside subscription and user forms. Cannot be used within itself (e.g. login in login).

A simple example of implementing a login form on the front end of your publication:

{{ if ! $campsite->user->logged_in }}
    <p>Login</p>
    {{ if $campsite->login_action->is_error }}
        <p>There was an error logging in: {{ $campsite->login_action->error_message }}</p>
    {{ /if }}
    {{ login_form submit_button="Login" button_html_code="class=\"submitbutton\"" }}
        <p>User ID: {{ camp_edit object="login" attribute="uname" }}</p>
        <p>Password: {{camp_edit object="login" attribute="password" }}</p>
    {{ /login_form }}
{{ else }}
    <p>Welcome {{ $campsite->user->name }}</p>
    <p><a href="?logout=true">Logout</a></p>
{{ /if }}
Attention: the logout requires this code in the head of every page:
{{ if $campsite->url->get_parameter('logout') == 'true' }}
<META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserId=; path=/">
<META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserKey=; path=/">
{{ $campsite->url->reset_parameter('logout') }}
<META HTTP-EQUIV="Refresh" content="0;url={{ uri }}">
{{ /if }}

Form: Search

Purpose:

Generate the search form and data fields for searching keywords in published articles. By default the search action is performed in the current publication only.

Syntax:

{{ search_form [template="<template_name>"] submit_button="<button_name>"
               [html_code="<html_code>"]
               [button_html_code="<html_code>"] }}
<list_of_instructions> 
{{ /search_form }}

  • <template_name> is the name of the next template to be requested from search form.
  • <button_name> is the name of the button for submitting the form.
  • html_code: you can insert whatever HTML code you want in the <form> statement; e.g.: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; e.g.: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

The list of instructions may contain any instruction allowed in the current context.

Setting the search scope: whether to search in all publications, in the current publication, in the current issue or in the current section. Insert the following field in the search form:

{{ camp_select object="search" attribute="level" }}

Constraints:

Can not be used within itself (e.g. search in search).

 


Form: Comment

Purpose:

Generate the form and default data fields for article comment submit. Inside the form camp_edit statements can be used to generate article comment input fields.

Syntax:

{{ comment_form [template="<template_name>"]
                submit_button="<submit_button_name>"
                [preview_button="<preview_button_name>"]
                [html_code="<html_code>"]
                [button_html_code="<html_code>"] }}
<list_of_instructions>
{{ /comment_form }}
  • <template_name>: the name of the next template to be requested when submitting the comment
  • <submit_button_name>: the name of the button for submitting the comment
  • <preview_button_name>: the name of the button for previewing the comment
  • html_code: you can insert whatever HTML code you want in the <form> statement; e.g.: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; e.g.: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

 


Form: User

Purpose:

Generate the form and data fields for adding a new user or editing an existing user data.

Syntax:

{{ user_form submit_button="<button_name>" [template="<template_name>"]
             [html_code="<html_code>"]
             [button_html_code="<html_code>"] }}
<list_of_instructions>
{{ /user_form }}
  • <template_name> is the name of the next template to be requested from user form.
  • <button_name> is the name of the button for submitting the form.
  • html_code: you can insert whatever HTML code you want in the <form> statement; e.g.: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; e.g.: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

Constraints:

Can not be used inside subscription and login forms. Can not be used within itself (ex.: user in user).

 


Form: Subscription

Purpose:

Generate the form and default data fields for subscription. Inside this can be used Edit and Select statements to generate fields for every section on issue.

Syntax:

{{ subscription_form type="<subscription_type>" [template="<template_name>"]
                     submit_button="<button_name>"
                     [total="<total_field_name>"]
                     [html_code="<html_code>"]
                     [button_html_code="<html_code>"] }}
<list_of_instructions>
{{ /subscription_form }}
  • <subscription_type> has two values: by_publication and by_section
  • <template_name> is the name of the next template to be requested from subscription form.
  • <button_name> is the name of the button for submitting the form.
  • <total_field_name> is the name of the field where the total payment is written.
  • <evaluate_button_name> is the name of the evaluate button (when pressing this button the total payment is updated in the total field.
  • html_code: you can insert whatever HTML code you want in the <form> statement; e.g.: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; e.g.: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

Constraints:

Cannot be used inside user and login forms. Can not be used within itself (ex.: subscription in subscription).

 

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
where:
  • fromstart: prints the parameters received at the start of 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 on the current comment id to another page for display purposes.

 

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 version 3.2.2.

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

Example:

{{ 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">

 

Edit Login

Purpose:
Generates a text input field for entering a subscriber's login user name or password. Use this to allow a subscriber to login to your site. These statements should be used inside the login form.

Syntax:

{{ camp_edit object="login" attribute="<attribute>"
             [html_code="<HTML_code>"] [size ="<field_length>"] }}

where <attribute> being one of the following:

  • uname: allows login name input
  • password: allows password input

Constraints:

The login edit fields can be used only inside the login form.

 

Edit Search

Purpose:
Generates a text input field so that a user can search for articles on your site. This statement should be used inside the search form.

Syntax:

{{ camp_edit object="search" attribute="<attribute>"
             [html_code="<HTML_code>"] [size ="<field_length>"] }}
with <attribute> being one of the following:
  • keywords: allows search keywords input
  • start_date: select only articles published starting on the selected date
  • end_date: select only articles published up to the selected date
Constraints:
The search edit field can be used only inside the search form.

 

Edit Comment

Purpose:
Generates text fields so that a user can enter a comment. This statement should be used inside the comment form.

Syntax:

{{ camp_edit object="comment" attribute="<attribute>"
             [html_code="<HTML_code>"]
             [size ="<field_length>"]
             [columns="<max_columns>"]
             [rows="<max_rows>"] }}
with <attribute> being one of the following:
  • nickname: a place for the user to type in a nickname
  • reader_email: a place for the user to type in their email address; this field is optional for logged in readers because the email can be read from the subscribers database
  • subject: a place for the user to type in a subject line for their comment
  • content: a place for the user to type in their comment.  
The attributes reader_email, subject and content are mandatory in each Edit Comment form.

Note

columns and rows parameters were implemented starting with version 3.2.2. Constraints:
The comment edit field can be used only inside the comment form.

 

Edit CAPTCHA

Purpose:
Generates a text field allowing the user to input the CAPTCHA code for spam control. This statement should be used inside the comment form.

Syntax:

{{ camp_edit object="captcha" attribute="code"
             [html_code="<HTML_code>"] [size ="<field_length>"] }}

 

Edit User

Purpose:
Generates a text input field for editing the selected user attribute. This statement should be used inside the user form.

Syntax:

{{ camp_edit object="search" attribute="<attribute>"
             [html_code="<HTML_code>"]
             [size ="<field_length>"]
             [columns="<max_columns>"]
             [rows="<max_rows>"] }}
with <attribute> being one of the following:
  • name
  • uname
  • email
  • city
  • str_address
  • state
  • phone
  • fax
  • contact
  • second_phone
  • postal_code
  • employer
  • position
  • how
  • languages
  • field1
  • field2
  • field3
  • field5
  • interests
  • improvements
  • text1
  • text2
  • text3
  • password
  • passwordagain
The parameters (name, uname, email, city...) are fields describing the user's data;  field1-field5, text1-text3 are extra fields for storing extra information of your choosing.

Note

columns and rows parameters were implemented starting with version 3.2.2. Constraints:
The user edit field can be used only inside the user form.

 

Edit Subscription

Purpose:
Generates an input field for editing the subscription time for a certain section. The section must be defined in the template environment. This statement should be used inside the subscription form.

Syntax:

{{ camp_edit object="search" attribute="time"
             [html_code="<HTML_code>"] [size ="<field_length>"] }}
Constraints:
The subscription edit field can be used only inside the subscription form.

 

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\"" }}

will output a popup list of available countries:

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

 

Select Login

Purpose:
Generates a check box; if checked the user session will be remembered for a period of two weeks so the user will not have to login again. This statement should be used inside the login form.

Syntax:

{{ camp_select object="login" attribute="rememberuser"
               [html_code="<HTML_code>"] }}
Constraints:
The select login field can be used only inside the login form.

 

Select Search

Purpose:

Generates a check box or a popup list for selecting the search mode or the search level respectively. This statement should be used inside the search form.

Syntax:

{{ camp_select object="search" attribute="<attribute>"
               [html_code="<HTML_code>"] }}
with <attribute> being one of the following:
  • mode: if checked the search will return articles that contain all entered keywords; if not checked it will return articles that contain at least one keyword
  • level: allows the reader to select the scope of the search: multiple publications, publication, issue, section.
  • section: select only articles that are in the given section
  • issue: select only articles that are in the given issue

Contraints:

The select search field can be used only inside the search form.

 

Select User

Purpose:
Generates a dropdown list or radio-buttons for selecting values for the given fields. This statement should be used inside the user form.

Syntax:

{{ camp_select object="user" attribute="<attribute>"
               [html_code="<HTML_code>"] }}
with <attribute> being one of the following:
  • gender
  • title
  • country
  • age
  • employertype
  • pref1
  • pref2
  • pref3
  • pref4
The parameters (country, title, gender...) are fields describing the user information; pref1-pref4 are extra fields for storing extra information - the publication administrator sets their meaning. 

Constraints:
The select user field can be used only inside the user form.

 

Select Subscription

Purpose:
Special-purpose input for subscription data.

Syntax:

{{ camp_select object="subscription" attribute="<attribute>"
               [html_code="<HTML_code>"] }}
with <attribute> being one of the following:
  • section: generates a checkbox for selecting the current section in subscription form; use together with "List of Sections" (see also "Creating reader subscriptions through the template language")
  • allLanguages: generates a checkbox allowing the user to choose a subscription to all available languages
  • languages: generates a multiple selection list allowing the user to select individual languages; this selection list is automaticaly deactivated if the user chose to subscribe to all available languages.

Constraints:
The select subscription field can be used only inside the subscription form.

 

CAPTCHA ImageLink

Purpose:

"captcha_image_link" will insert the link for the CAPTCHA image. Use inside an "img" HTML tag as follows:

<img src="../{{ captcha_image_link }}">
Syntax:
{{ captcha_image_link }

 



your comment:
name :
comment :

If you can't read the word, click here
word :