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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

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


Go to End


6 Posts   1444 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 %>