Skip to content

Instantly share code, notes, and snippets.

@charlycoste
Last active November 15, 2020 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlycoste/9414887 to your computer and use it in GitHub Desktop.
Save charlycoste/9414887 to your computer and use it in GitHub Desktop.
{{! DO NOT EDIT THIS FILE! Use an override template instead. }}
<form method="post" action={{ action }}>
<div class="maincontentheader">
<h1>{{ title }}</h1>
</div>
{{# warnings }}
<div class="warning">
<h2>{{ title }}</h2>
<ul>
<li>{{ message }}</li>
</ul>
</div>
{{/ warnings }}
{{# form.fields }}
<div class="block">
<label for="{{id}}">{{label}}</label><div class="labelbreak"></div>
<input class="halfbox" type="{{type}}" size="10" name="{{name}}" id="{{id}}" value="{{value}}" tabindex="1" />
</div>
{{/ form.fields }}
{{# RememberMeTimeout }}
<div class="block">
<input type="checkbox" tabindex="1" name="Cookie" id="id3" /><label for="id3" style="display:inline;">{"Remember me"|i18n("design/admin/user/login")}</label>
</div>
{{/ RememberMeTimeout }}
<div class="buttonblock">
<input class="defaultbutton" type="submit" name="LoginButton" value="{{ i18n.LoginButton }}" tabindex="1" />
<input class="button" type="submit" name="RegisterButton" value="{{ i18n.SignUp }}" tabindex="1" />
</div>
{{# showForgotPasswordLink }}
<p><a href={'/user/forgotpassword'|ezurl}>{'Forgot your password?'|i18n( 'design/standard/user' )}</a></p>
{{/ showForgotPasswordLink}}
<input type="hidden" name="RedirectURI" value="{{User.redirect_uri}}" />
{{# post_data }}
<input name="Last_{{key}}" value="{{item}}" type="hidden" /><br/>
{{/ post_data}}
</form>
<?php
//...
$context = 'design/standard/user';
if ($loginWarning) {
$warnings[] = array(
'title' => ezpI18n::tr($context, 'Could not login'),
'message' => ezpI18n::tr($context, 'A valid username and password is required to login.')
);
} elseif(!$siteAccessAllowed) {
$warnings[] = array(
'title' => ezpI18n::tr($context, 'Access not allowed'),
'message' => ezpI18n::tr($context, 'You are not allowed to access %1.', null, array($site_access['name']))
);
}
//...
{* DO NOT EDIT THIS FILE! Use an override template instead. *}
<form method="post" action={"/user/login/"|ezurl}>
<div class="maincontentheader">
<h1>{"Login"|i18n("design/standard/user")}</h1>
</div>
{if $User:warning.bad_login}
<div class="warning">
<h2>{"Could not login"|i18n("design/standard/user")}</h2>
<ul>
<li>{"A valid username and password is required to login."|i18n("design/standard/user")}</li>
</ul>
</div>
{else}
{if $site_access.allowed|not}
<div class="warning">
<h2>{"Access not allowed"|i18n("design/standard/user")}</h2>
<ul>
<li>{"You are not allowed to access %1."|i18n("design/standard/user",,array($site_access.name))}</li>
</ul>
</div>
{/if}
{/if}
<div class="block">
<label for="id1">{"Username"|i18n("design/standard/user",'User name')}</label><div class="labelbreak"></div>
<input class="halfbox" type="text" size="10" name="Login" id="id1" value="{$User:login|wash}" tabindex="1" />
</div>
<div class="block">
<label for="id2">{"Password"|i18n("design/standard/user")}</label><div class="labelbreak"></div>
<input class="halfbox" type="password" size="10" name="Password" id="id2" value="" tabindex="1" />
</div>
{if and( ezini_hasvariable( 'Session', 'RememberMeTimeout' ), ezini( 'Session', 'RememberMeTimeout' ) )}
<div class="block">
<input type="checkbox" tabindex="1" name="Cookie" id="id3" /><label for="id3" style="display:inline;">{"Remember me"|i18n("design/admin/user/login")}</label>
</div>
{/if}
<div class="buttonblock">
<input class="defaultbutton" type="submit" name="LoginButton" value="{'Login'|i18n('design/standard/user','Button')}" tabindex="1" />
<input class="button" type="submit" name="RegisterButton" value="{'Sign Up'|i18n('design/standard/user','Button')}" tabindex="1" />
</div>
{if ezini( 'SiteSettings', 'LoginPage' )|eq( 'custom' )}
<p><a href={'/user/forgotpassword'|ezurl}>{'Forgot your password?'|i18n( 'design/standard/user' )}</a></p>
{/if}
<input type="hidden" name="RedirectURI" value="{$User:redirect_uri|wash}" />
{section show=and( is_set( $User:post_data ), is_array( $User:post_data ) )}
{section name=postData loop=$User:post_data }
<input name="Last_{$postData:key|wash}" value="{$postData:item|wash}" type="hidden" /><br/>
{/section}
{/section}
</form>
@charlycoste
Copy link
Author

Login.tpl is the original template. It uses some operators like ezurl, ezini and so on...
A web integrator who doesn't know about eZ Publish can't figure out that this kind of operator exist.
Moreover, it makes it difficult to maintain! For now, we are using [SiteSetting].LoginPage at line 48 but, maybe we will need to rename it [SiteSetting].LoginPageStyle later... This update should not be concerning HTML code, but only application code!

A logicless template doesn't care about this kind of aspect. It uses variables and arrays. You code it once, then it's OK. If we need to call a different function, or change a setting, it's a work for the PHP developer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment