MyBB Community Forums

Full Version: Ignore User Profile Field If Empty
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to add in some cool areas for others to use to be able to stylize their profile page to their liking so its not just the normal ol' theme.

BUT for example:
When I add in the user custom field for "Body Background Image" and they do not fill it out with an image, the body background goes to black.
I want for it to instead of going to black if the field is empty, to just not do anything at all (as if the field wasn't even there).

I've seen this done on other MyBB forums so I know it's possible.

Here's my code I'm using for the body background image:
<body style="background-image: url('{$userfields['fid19']}');"></body>

http://ltts.wolvenlore.com/index.php <-- Forum
You need a plugin like Template Conditionals which I mentioned in your previous topic: http://mybbhacks.zingaburga.com/showthread.php?tid=464

<body <if $userfields['fid19'] then>style="background-image: url('{$userfields['fid19']}');"</if>></body>
Okay, I'll go download that plugin! Thanks!

If I wanted to use these extra conditionals would I be able to implement them into CSS or would I have to use html-->style like in the <body> tag?
Only in templates.
I mean like in the template would I be able to put it in CSS like:

<style>
body {userfield for bg in here}
</style>
Still looking for an answer to previous question.
Quote:I mean like in the template would I be able to put it in CSS like:

<style>
body {userfield for bg in here}
</style>

If you have any suggestions or answers that would be lovely!