2 users online. Create an account or sign in to join them.Users
Login form injection
Keep anonymous users out by simple attaching the "Login Info" even.
Description
This utility injects a author login-form on every page when two conditions are fullfilled:
- Event login-info is attached to the page
- User is not logged in
Otherwise, the regular templates will be executed. This provides a handy, site-wide login-check without the need of custom XSLT everywhere you want to use it.
XSLT
View Raw
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
It is very important that you are using <xsl:include /> instead of
<xsl:import /> to include this template, otherwise this util will not work!
Background: templates in an imported stylesheet will be overwritten by
templates in the current stylesheet while the ones being included will not.
This util assumes that your master matches "/" and your page matches "data".
-->
<xsl:template match="data[events/user/@logged-in = 'false']">
<form action="{$root}/symphony/" method="post">
<label>Username
<input name="username" type="text" />
</label>
<label>Password
<input name="password" type="password" />
</label>
<input name="action[login]" type="submit" value="Login" />
<input name="redirect" type="hidden" value="{$current-path}" />
</form>
</xsl:template>
</xsl:stylesheet>