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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

/Security/logout; how to put programatically in header?


Go to End


2 Posts   2036 Views

Avatar
pbt

Community Member, 3 Posts

13 January 2015 at 6:30am

I found that it is possible to programaticaly put login/logout buttons in header (in Silverstripe CMS) with this code.

<% if CurrentMember %>
<a href="/Security/login">Log in</a>
<% else %>
<a href="/Security/logout">Log out</a>
<% end_if %>

If I put "/Security/login" and "/Security/logout" in page name then it works, But if I put it in page template Page.ss then I cant see it (after sitename/dev/build and sitename/?flish=all)

Can someone help with Silverstripe 3.1 and "simple" template. Or give me any other clue.

Avatar
JonShutt

Community Member, 244 Posts

5 February 2015 at 3:33am

that should work - if it's in the right place in the template.
make sure it's in the Page.ss file, not 'Layout/Page.ss' file so that it appears on each page

then ?flush=all to refresh the cache.