Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Adding "You're logged in as" to a page

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 3380 Views
  • Bruce
    Avatar
    Community Member
    29 Posts

    Adding "You're logged in as" to a page Link to this post

    Hi,
    I am putting together a site which has a members section,
    and I want to be able to include a section in the top of the page with:
    Login | "You're Logged in as" | Logout | Change password
    much like the top right corner of these forums.
    So is there a chunk of code, or recipe, or example
    that I can use in a template in order to get this
    ... or even what variables I might be looking for?
    //BWS

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    you can use CurrentMember I think. So you can do things like

    <% if CurrentMember %>
    ...
    <% end_if %>

    and Hello $CurrentMember.FirstName

    Explained rather shortly on http://doc.silverstripe.com/doku.php?id=built-in-page-controls&s=currentmember

  • Bruce
    Avatar
    Community Member
    29 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    Mmmm Terse may be a better word.
    I take it that documentation is still a nice to have fo rSilverstripe.
    Considering this is active in the corner of the CMS, I would have thought this kind of thing would be available.
    Is there any plan for a User Manual/User Guide beyond the (frequently) cryptic wiki?
    //BWS

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    hey bruce, we're currently looking for book authors: http://silverstripe.com/help-write-SilverStripe-book/

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    Everyone would love more documentation. We do try and write as much as we can but the time we can spend on this on top of everything else the guys have going on, somethings always going to give.

    We are trying to make an effort in this area and I in particular am very keen to help out as much as possible but we do rely alot on the community to help out with documentation.

    If you have suggestions where the documentation is too brief feel free to add it to http://doc.silverstripe.com/doku.php?id=documentation-requests. On that site you can submit ideas and see open requests that you can complete. If you make a request on that page it would be great as then we can see where people are getting lost/confused

  • Bruce
    Avatar
    Community Member
    29 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    Okay,
    I've constructed

    <% if CurrentMember %>
    <p>Logged in as: $CurrentMember.FirstName </p>
    <% else %>
    <p> Not logged in </p>
    <% end_if %>


    at the top of the page & it is working fine when the page requires authentication,
    but as soon as you move to (say) the home page
    which doesn't require authentication, "Not logged in" appears!
    Is the a session-based parameter around this?
    $CurrentMember seems to be true only if authentication has been invoked?
    //BWS

  • Bruce
    Avatar
    Community Member
    29 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    Nooo.
    Looks like an ugly caching problem,
    Grrrrrrr
    //BWS

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Adding "You're logged in as" to a page Link to this post

    Try putting HTTP::set_cache_age(0) into your _config.php.

    I think we should make that the default for 2.3...

    3380 Views
Page: 1 2
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.