Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

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

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

Adding "You're logged in as" to a page


Go to End
Reply

10 Posts   3528 Views

Avatar
Bruce

13 April 2008 at 1:11pm (Last edited: 13 April 2008 1:13pm), Community Member, 29 Posts

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

Avatar
Willr

14 April 2008 at 6:52pm Forum Moderator, 5511 Posts

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

Avatar
Bruce

17 April 2008 at 8:23pm Community Member, 29 Posts

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

Avatar
Ingo

17 April 2008 at 10:42pm Forum Moderator, 801 Posts

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

Avatar
Willr

17 April 2008 at 10:49pm Forum Moderator, 5511 Posts

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

Avatar
Bruce

19 April 2008 at 6:13pm (Last edited: 19 April 2008 6:16pm), Community Member, 29 Posts

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

Avatar
Bruce

19 April 2008 at 6:19pm Community Member, 29 Posts

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

Avatar
Sam

21 April 2008 at 1:06pm Administrator, 685 Posts

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

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

Go to Top