SilverStripe 4.7 Custom login page not working

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

I’m trying to create a custom login page so I can add my own stylesheet, I’m not updating the actual login form.

I’ve seen in various posts that added a Security_login.ss to the templates/Layout folder will do the trick, but it’s not working for me. I’ve also added the Security_login.ss template to the top level templates folder - nothing. I’ve added it to to templates/SilverStripe/ThemeName/Layout - nothing. I’ve even added it to all three.

What am I missing here? Do I need to add a use: … in the PageController.php? I’ve done this previously in SS3 without any issues.

Hi Robin

The path to the new template should just be templates/Security_login.ss rather than ‘templates/Layout/Security.ss’ as there is no Layout method on the Security controller.

Further, if you want the same changes on all of the security actions (eg. lostpassword etc) then you could just use Security.ss rather than Security_login.ss

Thank you Kaftka,
I’ve removed my previous Security_login.ss files and added Security.ss to the templates folder (see image).
I’ve done a dev/build?flush=all, and I still don’t get the new template.
I don’t need to add anything to my .env or a config file?

Further testing, I’ve tried the same thing on a brand new SS 4.8 install on the simple theme and it still doesn’t work.
I must be missing something, can someone please shed some light on this?

Hi Robin, my apologies. The later versions of Silverstripe come bundled with the login-forms theme.

You should be able to override which Security template is pulled by adding this to your app/_config/themes.yml

SilverStripe\LoginForms\EnablerExtension:
  login_themes:
    - '$default'
    - 'tourism'

See reference:

The above docs recommend against replacing the template. If you are using this template and just want to add some additional custom css, have a look at using an extension to SilverStripe\Security\Security to add the css file via the Requirements API instead

Hope this helps

Thanks Kaftka,
I’ve always looked to the official docs for solutions and never to the github repo - lesson learnt.
Please see below for the solution.
app/_config/themes.yml

Before:
- ‘#login-forms

SilverStripe\LoginForms\EnablerExtension:
login_themes:
- ‘$default’
- ‘tourism’

Name: mytheme

SilverStripe\View\SSViewer:
themes:
- ‘$public’
- ‘tourism’
- ‘$default’

/templates/Security.ss
Add in your header etc.
/templates/Layout/Security.ss
Add your $Form and content in there.