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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Looking for a way to target the CMS Login page using <% if RecordClassName = ??? %>


Reply

4 Posts   591 Views

Avatar
RichMcNabb

15 May 2012 at 11:18am Community Member, 34 Posts

Hi there,

I am looking for a way the target the login form to display a default heading (e.g)
<h1><% if RecordClassName = ??? %>Please login to the CompanyName website<% else %>$Heading<% end_if %></h1>

I know I can create a Security_login.ss but in this case I need to be more specific. Any help would be greatly appreciated. Cheers!

- Rich

Avatar
Willr

20 May 2012 at 12:19pm Forum Moderator, 5511 Posts

Well ClassName will match any security page (login, forgot password etc) so if thats not an issue you can use <% if ClassName = Security %> otherwise you'll need a function in your Page.php which sniffs for the title (you can't have spaces in your <% if %> for 2.*).

// mysite/code/page.php
function isLoginPage() {
return ($this->Title == "Login");
}

<% if isLoginPage %>

Avatar
RichMcNabb

21 May 2012 at 3:44pm (Last edited: 21 May 2012 3:54pm), Community Member, 34 Posts

Hi Will,

Thanks for the response for some reason your suggestion didn't work for me. However your code gave me an idea I could accomplish what I was wanting to do using:
<% if URLSegment=Security %>

Thanks again :)

- Rich

Avatar
Willr

21 May 2012 at 3:58pm Forum Moderator, 5511 Posts

You may also have the same issue with using that as using ClassName = Security, in that forgot password, login and all security/ pages may by oversight all use security has the url segment.