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:

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   967 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.