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.

General Questions /

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

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

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


Go to End


4 Posts   1416 Views

Avatar
RichMcNabb

Community Member, 34 Posts

15 May 2012 at 11:18am

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

Forum Moderator, 5523 Posts

20 May 2012 at 12:19pm

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

Community Member, 34 Posts

21 May 2012 at 3:44pm

Edited: 21/05/2012 3:54pm

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

Forum Moderator, 5523 Posts

21 May 2012 at 3:58pm

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.