User and login templates
This page is for designers who style the account pages of a public site: sign in, register, forgotten password, change
password, profile. They belong to the user module, whose templates live in user/ of the design.
Contents
- The templates
- Field names you must keep
- Accessible and password-manager friendly
- The signed-in state in the frame
- Caching
The templates
design/standard/templates/user/: login.tpl, register.tpl, success.tpl, activate.tpl, forgotpassword.tpl,
password.tpl, edit.tpl, setting.tpl and the mail templates (forgotpasswordmail.tpl,
password_changed_mail.tpl, registrationinfo.tpl). Copy the ones you restyle into your design. The media design has
its own versions (its stylesheet account.css draws them, by its comment).
Field names you must keep
The module reads the posted fields by name. In user/login.tpl: Login, Password, LoginButton, RedirectURI,
Cookie (stay signed in) and RegisterButton; the form posts to /user/login. Keep the names and the hidden
inputs; change only markup and classes. Registration and profile forms draw the user class's fields with
attribute_edit_gui (Datatype edit templates).
Accessible and password-manager friendly
<label for="login-name">'Username or email'|i18n( 'design/mytheme/user' )</label>
<input id="login-name" name="Login" type="text" autocomplete="username" required>
<label for="login-password">'Password'|i18n( 'design/mytheme/user' )</label>
<input id="login-password" name="Password" type="password" autocomplete="current-password" required>On the change-password page use autocomplete="new-password". Show errors next to the fields and in a summary
(Accessible forms). The forgotten password page must not reveal whether an
address has an account; the kernel's templates were changed for that, keep their wording.
The signed-in state in the frame
In the pagelayout, $current_user.is_logged_in tells whether a visitor is signed in;
$current_user.contentobject.name is their name. Link to /user/login, /user/logout and /user/edit with ezurl
(Pagelayout variables).
Caching
Anything showing the user's name or state must be outside the view cache (the pagelayout is not view-cached) and, in a
cache-block, keyed by the user ($current_user.contentobject_id) (Cache-block).
Related pages
- Forms in templates
- Role and policy operators
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.