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   3534 Views

Avatar
Bruce

Community Member, 29 Posts

13 April 2008 at 1:11pm

Edited: 13/04/2008 1:13pm

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

Forum Moderator, 5513 Posts

14 April 2008 at 6:52pm

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

Community Member, 29 Posts

17 April 2008 at 8:23pm

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

Forum Moderator, 801 Posts

17 April 2008 at 10:42pm

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

Avatar
Willr

Forum Moderator, 5513 Posts

17 April 2008 at 10:49pm

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

Community Member, 29 Posts

19 April 2008 at 6:13pm

Edited: 19/04/2008 6:16pm

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

Community Member, 29 Posts

19 April 2008 at 6:19pm

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

Avatar
Sam

Administrator, 685 Posts

21 April 2008 at 1:06pm

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