Skip to content

Instantly share code, notes, and snippets.

@garethredfern
Created August 11, 2013 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save garethredfern/6205325 to your computer and use it in GitHub Desktop.
Save garethredfern/6205325 to your computer and use it in GitHub Desktop.
Display content behind a login area with Statamic.
{{ member:login return="top-secret" }}
<div>
<input type="text" name="username" id="username" placeholder="Username" >
</div>
<div>
<input type="password" name="password" id="password" placeholder="Password" >
</div>
<div>
<input type="submit" value="Log in">
</div>
</div>
{{ /member:login }}
<!-- Log in form -->
<a href="{{ member:logout return="/" }}">Logout</a>
<!-- Log out link -->
title _template _fieldset
Top Secret
top-secret
page

No one can see this unless they log in.

{{ if logged_in }}
<section role="main">
<h2>{{ title }}</h2>
{{ content }}
</section><!-- END role="main" -->
{{ else }}
<p>You need to log in to see this.</p>
{{ endif }}
<!-- This is the template which will display the content using a conditional only if you are looged in -->
@garethredfern
Copy link
Author

For more information I have written a short article here.

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