The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
Yep, it's me again.
![]() I have been using the code below to display custom fields in my new custom memberlist. It's been working great so far, but I just realized it doesn't work like I intended when the custom field values are from a multiple selection check box. Code:
{vb:raw userinfo.field17} Example: User can select any number of the following - Snacks, Breakfast, Lunch, Dinner So if they check Breakfast and Dinner, that is what I want the output to be in my template. Instead, the code above will output the number assocciated with that option. Thanks! ![]() |
#2
|
||||
|
||||
![]()
Custom Fields with more than one option are sorted based on the geometric formula. Meaning You would do something like this:
Userfield6(Radio, Select, Checkbox it doesn't matter) Yes(1) No(2) Maybe(4) Never(8) PHP Code:
so to continue it would be 1,2,4,8,16,32,64 etc.. |
#3
|
||||
|
||||
![]()
I checked the values in the databse to make sure I had them correct, but this doesn't seem to work. My template is still outputting numbers instead of text values.
PHP Code:
Code:
{vb:raw userinfo.field23} |
#4
|
||||
|
||||
![]()
I didn't convert it to template format
Something like this: <vb:if condition="$userfield['field23'] & 1"> Yes <vb:elseif condition="userfield['field23'] & 2"> No <vb:endif> |
#5
|
||||
|
||||
![]()
I am using this in my template and am getting an error when I try to save the template. Can anyone see a problem with this?
Code:
<vb:if condition="$userfield['field23'] & 1"> Unknown <vb:elseif condition="userfield['field23'] & 2" /> No Food <vb:elseif condition="userfield['field23'] & 24" /> Breakfast <vb:elseif condition="userfield['field23'] & 32" /> Lunch <vb:elseif condition="userfield['field23'] & 63" /> Dinner <vb:elseif condition="userfield['field23'] & 8" /> Snacks </vb:if> The following error occurred when attempting to evaluate this template: %1$s This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. |
#6
|
|||
|
|||
![]()
All your condition expressions except the first one are missing the $ in front of "userfield".
|
#7
|
||||
|
||||
![]()
I can't believe I didn't see that!! Lol!
However, I was finally able to save the template changes, but that code is not outputting anything. Grrr! This is what I have... Code:
<vb:if condition="$userfield['field23'] & 1"> Unknown <vb:elseif condition="$userfield['field23'] & 2" /> No Food <vb:elseif condition="$userfield['field23'] & 24" /> Breakfast <vb:elseif condition="$userfield['field23'] & 32" /> Lunch <vb:elseif condition="$userfield['field23'] & 63" /> Dinner <vb:elseif condition="$userfield['field23'] & 8" /> Snacks </vb:if> |
#8
|
|||
|
|||
![]()
It might help to temporarily output the value of $userfield['field23'] to see what's going on.
That seems like a strange set of bits to check (normally they'd be 1, 2, 4, 8, 16, 32, 64, etc), but I don't know exactly how they're being used so what you have could be correct. |
#9
|
||||
|
||||
![]()
I got those numbers from the database. They may have skipped around from me deleting and adding options. How can I temporarily output the values?
|
#10
|
|||
|
|||
![]()
OK, but the 63 seems strange since 63 in binary is 111111, so that condition will be true if any of those bits are set. That would mean that the last "Snacks" condition would never be displayed. (Maybe you just want "==" instead of "&"?)
Quote:
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|