MyBB Community Forums

Full Version: Else/If in template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to set up a profile background image using custom profile fields.

Currently I've set up a style that has this:
.profile-bg {
background-image: url({$userfields['fid4']});
}	

However; when I use this code, the default .profile-bg is being overwritten by the new code and if the user doesn't have an image - ti's just blank. I'd like to replace that blank image with a default image IF the user has not filled out the field with an image location.
Hi,

could be something similar to this:

if (url({$userfields['fid4']}) === 'http://YOURURL.com/forum/images/Blank_default_image.jpg' || url({$userfields['fid4']}) === '' ) {
.profile-bg {
background-image: url("http://YOURURL.com/forum/images/New_Blank_image.jpg");
}
}
else {
.profile-bg {
background-image: url({$userfields['fid4']});
}
}
(2019-06-25, 07:54 AM)NoRules Wrote: [ -> ]Hi,

could be something similar to this:

if (url({$userfields['fid4']}) === 'http://YOURURL.com/forum/images/Blank_default_image.jpg' || url({$userfields['fid4']}) === '' ) {
.profile-bg {
background-image: url("http://YOURURL.com/forum/images/New_Blank_image.jpg");
}
}
else {
.profile-bg {
background-image: url({$userfields['fid4']});
}
}

Thanks for the feedback and help Smile