Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 24 Mar 2011, 06:13
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
Display custom field in memberlist that contains multiple selections.

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So, if check box values are any combination of A,B,C,D - then that code outputs a number value according to the number value of boxes the user checked. How do I get it to output the actual textual value of the boxes checked by the user?

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!
__________________
~Jessica Bolin
www.motioncitymedia.net

Last edited by AFemaleProdigy; 24 Mar 2011 at 06:19.
Reply With Quote
  #2  
Old 24 Mar 2011, 17:05
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Real name: Ryan
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)


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This continues on each time you multiply the number by itself
so to continue it would be 1,2,4,8,16,32,64 etc..
Reply With Quote
  #3  
Old 24 Mar 2011, 18:18
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
~Jessica Bolin
www.motioncitymedia.net

Last edited by AFemaleProdigy; 24 Mar 2011 at 18:30.
Reply With Quote
  #4  
Old 24 Mar 2011, 18:58
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Real name: Ryan
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>
Reply With Quote
  #5  
Old 27 Nov 2011, 21:45
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
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?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Here is the error message:

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.
__________________
~Jessica Bolin
www.motioncitymedia.net
Reply With Quote
  #6  
Old 28 Nov 2011, 02:57
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
All your condition expressions except the first one are missing the $ in front of "userfield".
Reply With Quote
  #7  
Old 28 Nov 2011, 03:35
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
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...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Also, is using elseif appropriate if there may be multiple options set? For example: Breakfast, Lunch, Dinner
__________________
~Jessica Bolin
www.motioncitymedia.net

Last edited by AFemaleProdigy; 28 Nov 2011 at 03:42.
Reply With Quote
  #8  
Old 28 Nov 2011, 03:42
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #9  
Old 28 Nov 2011, 03:51
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
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?
__________________
~Jessica Bolin
www.motioncitymedia.net

Last edited by AFemaleProdigy; 28 Nov 2011 at 03:58.
Reply With Quote
  #10  
Old 28 Nov 2011, 03:55
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by AFemaleProdigy View Post
I got those number from the database.
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 "&"?)

How can I temporarily output the values?
I think you could just put {vb:raw userfield.field23} somewhere in the template.
Reply With Quote
  #11  
Old 28 Nov 2011, 04:17
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
Okay, you were right about the numbers. Some were wrong. I updated the numbers though and it still didn't do anything. I tried using == like you said and that didn't work. Did I do it like you were thinking... ?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
~Jessica Bolin
www.motioncitymedia.net
Reply With Quote
  #12  
Old 28 Nov 2011, 05:25
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, I went back and read the above posts again, and since it's multiple selection, I think you do want to use '&'. And are you sure $userfield is what you want to check? You might want $bbuserinfo[field23] (assuming this is displaying the data to the user who selected it, and not to another user (like an admin or someone).

Also, like you mentioned in an earlier post, since it's possible to have multiple options selected you don't want to use elseif, you would just want a bunch of if statements, like:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

etc.
Reply With Quote
  #13  
Old 28 Nov 2011, 21:18
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
This output will be shown to any usergroup type viewing it on a public profile and also in the custom member list I created. It is not meant to show the viewer their own personal selections, but to show the viewer the selection of whoever's profile they are viewing.
__________________
~Jessica Bolin
www.motioncitymedia.net
Reply With Quote
  #14  
Old 28 Nov 2011, 21:25
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
In that case you don't want to use $bbuserinfo, of course.
Reply With Quote
  #15  
Old 28 Nov 2011, 21:54
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Real name: Jessica Bolin
So this does not work either. Any ideas?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
~Jessica Bolin
www.motioncitymedia.net
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Miscellaneous Hacks Memberlist -- Custom Profile Field Sorting Oblivion Knight vBulletin 3.6 Add-ons 21 10 Jul 2013 09:25
Miscellaneous Hacks Custom Field Columns: Display Custom Fields in Two Columns on Memberlist Search calorie vBulletin 3.7 Add-ons 5 05 Aug 2008 09:50



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 08:15.

Layout Options | Width: Wide Color: