Can someone give me a hand for a sec... Custom UserFields

Code:
<xen:if is="{$user.customFields.service} == 'army'">
<a><img src="vault/icons/army.png" height="36px" width="36px" title="ARMY" alt="ARMY"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == 'navy'">
<a><img src="vault/icons/navy.png" height="36px" width="36px" title="NAVY" alt="NAVY"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == 'usmc'">
<a><img src="vault/icons/usmc.png" height="36px" width="36px" title="USMC" alt="USMC"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == 'usaf'">
<a><img src="vault/icons/usaf.png" height="36px" width="36px" title="USAF" alt="USAF"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == 'coastguard'">
<a><img src="vault/icons/coast.png" height="36px" width="36px" title="Coast Guard" alt="Coast Guard"></a>
</xen:if>
 
@RichardKYA thanks for your help , it won't show I've tried a million different variations of your code it just won't show anything, i even tested my fields out by clicking show in message user info and it showed the text answers so i know the profile field is set right here is where we are at

Code:
<xen:if is="{$user.customFields.service} == '1'">
<a><img src="vault/icons/army.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{xen:phrase ARMY}"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == '2'">
<a><img src="vault/icons/navy.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{xen:phrase NAVY}"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == '3'">
<a><img src="vault/icons/usmc.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{xen:phrase USMC}"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == '4'">
<a><img src="vault/icons/usaf.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{xen:phrase USAF}"></a>
</xen:if>
<xen:if is="{$user.customFields.service} == '5'">
<a><img src="vault/icons/coast.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{xen:phrase CoastGuard}"></a>
</xen:if>

zzzz.webp

here is proof the fields work

zzz.webp
 
in message user info via ...

Code:
<xen:include template="fixers1st" />

and i have a template named fixers1st
You have already edited the template to include the call to yours, you should just place the code that @Xon posted directly in the message_user_info template.
 
Do you use radio buttons or drop down menu?

I use something similar for members to show their headset/console in the postbit but my code is

Code:
<xen:if is="{$user.customFields.headset}"><img src="http://i155.photobucket.com/albums/s294/404error_head/Headset/{$user.customFields.headset}.png"  class="headset Tooltip" title="{$user.customFields.headset}";></xen:if>

So couldn't you use

Code:
<xen:if is="{$user.customFields.service}><img src="vault/icons/{$user.customFields.service}.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{$user.customFields.service}";>
</xen:if>

The image file names are case sensitive so must match exactly.
 
I guess the question is can a user have 2 different services? ARMY and USMC for example. That would determine if you should use a drop down or check boxes (or even multiple choice drop down).

But @OUTL4W pretty much has it if you only want one selection. I test this all and it works for me so not sure what you're doing wrong.
 
He's using checkboxes (clearly shown in his first post) and with checkboxes, users can obviously select multiple options. that's why your, Xon's and OUTL4W's suggestions don't work

I've been trying and even these don't work...

Code:
<xen:if is="{$user.customFields.service.0}">
     ARMY
   </xen:if>
<xen:if is="{$user.customFields.service.1}">
     NAVY
   </xen:if>

......OR......

<xen:if is="{$user.customFields.service} == '0'">
     ARMY
   </xen:if>
<xen:if is="{$user.customFields.service} == '1'">
     NAVY
   </xen:if>

I don't use custom fields in this manner, so it's not something I've done myself, but I think it's do with how the field value's are stored in the db.

Hopefully an XF Dev will chime in because knowing how to do this would be useful.
 
Last edited:
wow didnt think the issue could of been the fact im using check boxes

like i said im at work so wont be to a computer until like 6am

maybe we can get some incite on the check boxes or i just switch to drop down

dont really think people will be more than one branch but I could be wrong

thanks for everyone who is trying to figure this out
 
didnt think the issue could of been the fact im using check boxes
It's not an issue aside from how the code needs to work.



HTML:
<xen:if is="{$user.customFields.service.army}">
    <a><img src="vault/icons/army.png" height="36px" width="36px" title="ARMY" alt="ARMY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.navy}">
    <a><img src="vault/icons/navy.png" height="36px" width="36px" title="NAVY" alt="NAVY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.usmc}">
    <a><img src="vault/icons/usmc.png" height="36px" width="36px" title="USMC" alt="USMC"></a>
</xen:if>
<xen:if is="{$user.customFields.service.usaf}">
    <a><img src="vault/icons/usaf.png" height="36px" width="36px" title="USAF" alt="USAF"></a>
</xen:if>
<xen:if is="{$user.customFields.service.coastguard}">
    <a><img src="vault/icons/coast.png" height="36px" width="36px" title="Coast Guard" alt="Coast Guard"></a>
</xen:if>

upload_2016-5-27_18-38-9.webp
 
Well you could create a new custom profile field (service1) with the drop down menu method for experimentation

Code:
<xen:if is="{$user.customFields.service1}><img src="vault/icons/{$user.customFields.service1}.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{$user.customFields.service1}";>
</xen:if>
 
i already have indiviual check boxes for

oathkeeper
three percenter
nra member
concealed carry holder

and all them show fine

its just when trying to do a new question that has the branches of the military as options that it dont want to work

worst comes to worst i can them each individually but that is not ideal

here is all the inages showing except oathkeeper i didnt have it checked

http://www.mymilitia.com/threads/user-badges.27842/
 
Well you could create a new custom profile field (service1) with the drop down menu method for experimentation

Code:
<xen:if is="{$user.customFields.service1}><img src="vault/icons/{$user.customFields.service1}.png" height="36px" width="36px" class="Tooltip" data-offsetx="-7" data-offsety="-7" title="{$user.customFields.service1}";>
</xen:if>
That won't "loop" through choices. That would always resolve with the first choice the user inputs. That code would work fine for a single choice drop down or radio buttons.
 
This works on my dev site...

Code:
<xen:if is="{$user.customFields.service.1}">
    <a><img src="vault/icons/army.png" height="36px" width="36px" title="ARMY" alt="ARMY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.2}">
    <a><img src="vault/icons/navy.png" height="36px" width="36px" title="NAVY" alt="NAVY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.3}">
    <a><img src="vault/icons/usmc.png" height="36px" width="36px" title="USMC" alt="USMC"></a>
</xen:if>
<xen:if is="{$user.customFields.service.4}">
    <a><img src="vault/icons/usaf.png" height="36px" width="36px" title="USAF" alt="USAF"></a>
</xen:if>
<xen:if is="{$user.customFields.service.5}">
    <a><img src="vault/icons/coast.png" height="36px" width="36px" title="Coast Guard" alt="Coast Guard"></a>
</xen:if>
 
This works on my dev site...

Code:
<xen:if is="{$user.customFields.service.1}">
    <a><img src="vault/icons/army.png" height="36px" width="36px" title="ARMY" alt="ARMY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.2}">
    <a><img src="vault/icons/navy.png" height="36px" width="36px" title="NAVY" alt="NAVY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.3}">
    <a><img src="vault/icons/usmc.png" height="36px" width="36px" title="USMC" alt="USMC"></a>
</xen:if>
<xen:if is="{$user.customFields.service.4}">
    <a><img src="vault/icons/usaf.png" height="36px" width="36px" title="USAF" alt="USAF"></a>
</xen:if>
<xen:if is="{$user.customFields.service.5}">
    <a><img src="vault/icons/coast.png" height="36px" width="36px" title="Coast Guard" alt="Coast Guard"></a>
</xen:if>
That is pretty much exactly as I posted above except the numbers versus name.
 
That is pretty much exactly as I posted above except the numbers versus name.

Noice, didn't see your post, I wasted another 20mins on this for nothing lol

At first, I had my numbers starting from "0"....

Code:
<xen:if is="{$user.customFields.service.0}">
     ARMY
   </xen:if>
<xen:if is="{$user.customFields.service.1}">
     NAVY
   </xen:if>

...and it wasn't working, then I realised I just needed to start from "1" - lmao, such a simple fix.

We all got there in the end, so high fives all round

*high five*
 
Last edited:
This works on my dev site...

Code:
<xen:if is="{$user.customFields.service.1}">
    <a><img src="vault/icons/army.png" height="36px" width="36px" title="ARMY" alt="ARMY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.2}">
    <a><img src="vault/icons/navy.png" height="36px" width="36px" title="NAVY" alt="NAVY"></a>
</xen:if>
<xen:if is="{$user.customFields.service.3}">
    <a><img src="vault/icons/usmc.png" height="36px" width="36px" title="USMC" alt="USMC"></a>
</xen:if>
<xen:if is="{$user.customFields.service.4}">
    <a><img src="vault/icons/usaf.png" height="36px" width="36px" title="USAF" alt="USAF"></a>
</xen:if>
<xen:if is="{$user.customFields.service.5}">
    <a><img src="vault/icons/coast.png" height="36px" width="36px" title="Coast Guard" alt="Coast Guard"></a>
</xen:if>


against my better judgement i just nade this edit on my iphone and it works on my site even when selecting multiples it shows them

thank you!

i think somehow the numbers matter
 
Last edited:
Top Bottom