I think your code is correct.
I override conrete/single_pages/login.php of v.9.02, then I login with http once (result: no background image) and switch to https, login again an there it is, the desired login image.
I have no idea why, - I found out rather by accident. It’s all very tricky, you have to tinker a lot. Maybe somebody knows why.
Regards Carmel
It’s an older thread I know. But it’s probably helpful since the old way of adding a custom background to the login page does not work anymore.
We found a solution for the custom background-image on the login-page.
You can add the code below that adds some css. Apply the code in the file /application/bootstrap/app.php
Double check that your code (first lines till ) are not indented. This would throw an error. And provide your own url for the image. The example points to unsplash and shows a random image.
Hope this is helping some others.
Events::addListener('on_before_render', function() {
$customCSS = <<<EOT
<style>
.body-page-login {
background-color: gold;
background: url('https://source.unsplash.com/random/1920x1080?nature') no-repeat center center;
background-size: cover;
}
.body-page-login .login-page {
background: #252525;
}
.body-page-login .login-page .btn-primary {
background: #252525;
border-color: #252525;
}
.body-page-login .login-page-header {
padding: 25px 0;
}
</style>
EOT;
// get the current page object
$c = \Page::getCurrentPage();
// get one instance of the view object
$v = \View::getInstance();
// check that $c is an object before adding the custom CSS
if (is_object($c)) {
// get the permissions for the current page
$cp = new \Permissions($c);
// if the permissions allow for the page to be viewed, add the custom CSS
if ($cp->canViewPage()) {
$v->addFooterItem($customCSS);
}
}
});
Thanks @webpresso for this contribution.
Is there also a way to get rid of the background image on the welcome page?
It would be nice to use the same background as on the login page.
Hey adexec
Yes you can add some more css to override the background-image for the welcome-page too. Probably not the best way but it’s working and nothing should break anything. There should be an option as it used to be with whitelabeling.
add these lines to the example above before to the css part:
Testing 9.2.0 RC, the system wants to connect to source.unsplash.com again, and eventually loads the daily image for the background on the “Welcome” page.
The login page though loads the custom image.