SilverStripe 4.7 Custom login page not working

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 to the templates/Layout folder will do the trick, but it’s not working for me. I’ve also added the 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/ rather than ‘templates/Layout/’ 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 rather than

Thank you Kaftka,
I’ve removed my previous files and added 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

    - '$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.

- ‘#login-forms

- ‘$default’
- ‘tourism’

Name: mytheme

- ‘$public’
- ‘tourism’
- ‘$default’

Add in your header etc.
Add your $Form and content in there.

This is quite an old thread which has been marked as solved. If the solutions in this thread don’t cure your issue, please open a new thread with details of your code, what you’ve tried, etc. and we’ll try to help out.