Newscoop 3 Cookbook

Login and registration form

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 the 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; for example: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; such as: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

Constraints:

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

A simple implementation of a login form for the public website of your publication:

{{ if ! $gimme->user->logged_in }}
 <p>Login</p>
  {{ if $gimme->login_action->is_error }}
   <p>There was an error logging in:
   {{ $gimme->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 {{ $gimme->user->name }}</p>
 <p><a href="?logout=true">Logout</a></p>
{{ /if }}

The logout requires this code in the head of every page:

{{ if $gimme->url->get_parameter('logout') == 'true' }}
 <META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserId=; path=/">
 <META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserKey=; path=/">
 {{ $gimme->url->reset_parameter('logout') }}
 <META HTTP-EQUIV="Refresh" content="0;url={{ uri }}">
{{ /if }}

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

Filters:

<attribute> being one of the following:

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

Constraints:

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

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 only be used inside the login form.

Logout

There is no template keyword to logout a subscriber. Instead, just put these two lines in your logout.tpl file:

<META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserId=; path=/">
<META HTTP-EQUIV="Set-Cookie" CONTENT="LoginUserKey=; path=/"> 

Form - User

Purpose:

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

Syntax:

{{ user_form [template="<template_name>"] submit_button="<button_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 the 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; for example: {{ user_form .. html_code="id=\"my_id\"" }}
  • button_html_code: you can insert whatever HTML code you want in the button input field statement; such as: {{ user_form .. button_html_code="id=\"my_submit_id\"" }}

Constraints:

Cannot be used inside subscription and login forms. Cannot be used within itself (for example: user in user).

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

Filters:

<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 choice.

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

Constraints:

The user edit field can only be used inside the user form.

Select User

Purpose:

Generates a drop-down 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>"] }}

Filters:

<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 only be used inside the user form.



your comment:
name :
comment :

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