Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Creating login & logout button

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3097 Views
  • monnick
    Community Member
    6 Posts

    Creating login & logout button Link to this post

    I am just starting with Silverstripe and I am having a (very simple?) problem. What I want to do is simply create a login / logout button somewhere on the site, the default menubar would be a good place. This should be very easy I guess, but I don't know how to do it...

    On the back-end I could simply create a new menu-item which refers to /Security/login, but then it will still say "Login" after logging it, I would like it to disappear or change to logout. What is the best and simplest way to realize this?

    I have searched the SilverStripe documentation, but I couldn't find it. Can somebody please explain how this works or provide me a link to a page where it is described? Thanks in advance! :-D

  • purplespider
    Community Member
    81 Posts

    Re: Creating login & logout button Link to this post

    In your template:

    <% if CurrentMember %>
    // Show logout button
    <% else %>
    // Show login button
    <% end_if %>

    See http://spdr.me/qrVz for more info.

    Hope that helps!

  • Pigeon
    Community Member
    243 Posts

    Re: Creating login & logout button Link to this post

    The links would be:

    <a href="/Security/login">Log in</a>


    <a href="/Security/logout">Log out</a>

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.