MyBB Community Forums

Full Version: How would i do this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, i am adding some new features into the postbit of my forum, i basicly need a code so if fid5 is empty the features will not show, how would i do this?

Thanks.
Use the PHP in Templates plugin. The provided example should en-light you on how to do it.
Thank you, although i am still a little stuck on the actual code.

What i am wanting to achieve is an image that will only show if someone has got the fid5 field filled in, the information from this then gets put in the image src.

In example:

<img src="http://avatar.xboxlive.com/avatar/{$post['fid5']}/avatar-body.png">
And if fid5 isn't filled in, don't show the image? If that's what you want, this should work:

<if $post['fid5'] then>
<img src="http://avatar.xboxlive.com/avatar/{$post['fid5']}/avatar-body.png">
</if>
I'd use Template Conditionals for this rather than PHP in templates.

With template conditionals mod use this code to display it only if it isn't empty:
<if $post['fid5'] then>
HTML goes here!
</if>

How you could do it:
<if $post['fid5'] then>
<img src="http://avatar.xboxlive.com/avatar/{$post['fid5']}/avatar-body.png">
</if>

Example in use:
	<span class="userTitle">{$post['usertitle']}</span><br /><span class="smalltext">
			{$post['userstars']}
			{$post['groupimage']} 
			{$post['useravatar']}<br />
			{$post['user_details']}

<if $post['fid4'] then>
<br/>
Custom: <strong>{$post['fid4']}</strong>
</if>

Hope this helped Smile

EDIT: Above post beat me to it!
Thanks so much!