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

<% IF $URL doesn't include 'Security' ....


Go to End


6 Posts   1705 Views

Avatar
JonShutt

Community Member, 244 Posts

1 August 2011 at 10:17pm

Hi,

I've added a log in form etc to the header of my site (munromap.co.uk) by adding $LoginForm. All good.

However, if the user ends on original SS login page (links, incorrect password etc) then there are TWO login forms on the page - and the CSS is getting all messed up

I would like, on the /Security/ pages, to not show the log in page in the header - not just hide it via css, but actually not show it, so there aren't duplicated bits of forms around...

Any suggestions?

Avatar
swaiba

Forum Moderator, 1899 Posts

1 August 2011 at 11:21pm

Probably best to do the logic of the if within php, rather than with the tempate...

template.ss

<% if SecurityLoginPage %>
<% else %>
//show form
<% end_if %>

Page.php

function SecurityLoginPage() {
return (strpos($_GET['url'],'Security')!==false);  //note untested!
}

Avatar
Willr

Forum Moderator, 5523 Posts

3 August 2011 at 7:18pm

Or you can use ClassName (saves adding that method)

<% if ClassName = Security %>
<% else %>
...
<% end_if %>

Avatar
JonShutt

Community Member, 244 Posts

3 August 2011 at 7:51pm

Edited: 03/08/2011 7:56pm

Hi Willr - just tried that - sounds easier, but it made no change...

page just putting $ClassName on the page, i saw that the 'Security' pages are simply classname 'Page'...

so ended up using the function above - work fine...

Avatar
zenmonkey

Community Member, 545 Posts

4 August 2011 at 5:55am

Security Pages have an ID of 0 so you could filter for if ID=0

Avatar
martimiz

Forum Moderator, 1391 Posts

4 August 2011 at 8:27am

I think you can filter on <% if URLSegment != Security %> ... <% end_if %>