Announcement

Collapse
No announcement yet.

Multi-Selection Checkbox displays as numbers in profile rather the answer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi-Selection Checkbox displays as numbers in profile rather the answer

    I created a custom profile field using multi-selection check boxes, it displays the results as numbers however. Why is this?
    Michael Key - www.mikekey.com
    www.hrfbody.com - Hampton Roads F-Body

  • #2
    Because the selection is stored as a bitfield. You would need to decode the bitfield, and then query the 'profilefield' table to retrieve the textvalues.
    Want to take your board beyond the standard vBulletin features?
    Visit the official Member to Member support site for vBulletin Modifications: www.vbulletin.org

    Comment


    • #3
      Originally posted by MarcoH64
      Because the selection is stored as a bitfield. You would need to decode the bitfield, and then query the 'profilefield' table to retrieve the textvalues.
      How do you decode the bitfield? There is quite a few trying to fix up their profiles and this would be a huge boost to have that control.

      http://www.vbulletin.org/forum/showthread.php?t=101248

      Jaks

      Comment


      • #4
        Originally posted by jaks
        How do you decode the bitfield? There is quite a few trying to fix up their profiles and this would be a huge boost to have that control.

        http://www.vbulletin.org/forum/showthread.php?t=101248

        Jaks
        What he said.
        Michael Key - www.mikekey.com
        www.hrfbody.com - Hampton Roads F-Body

        Comment


        • #5
          I'm curious about how to do this too. I'm working on a custom template where part if the idea is to select multiple things in their profile, and then display them next to their name in the postbit.

          Can someone throw a bone here?

          Joel

          Comment


          • #6
            Also interested

            I'm also trying to figure out how the bitfields are decoded.
            In the mysql table there is a variable (a) assigned for the length of the array. Also, there are two other variables (one's not really a variable but the length of the string) that are also included for each checkbox.

            a = number of options + 1 (I don't know if this is correct)
            i = option number
            s = length of the option

            Each set of options creates a two digit number. Now, I have 8 options and only two are allowed to be selected so the number of digits may increase as you allow more values to be chosen.
            Instead of having a switch statement for 56 different possibilities I'd like to be able decode this array and the two digit string stored for each user but I can't seem to figure out the correlation between the two digits and the array.

            Any help would be great.

            Comment


            • #7
              I believe

              <if condition="$post[fieldX] & Y"> y is stored there, </if>

              works

              So for example

              <if condition="$post[field7] & 2"> They selected the second option.

              Comment


              • #8
                I might be misunderstanding what your code actually does, but what if you allow multiple selections? These are checkboxes and vbulletin gives you the option to allow more then one at a time and have those values stored.

                Comment


                • #9
                  <if condition$post[fieldx] & Y AND $post[fieldx] & Z">They checked x and y</if>

                  Comment


                  • #10
                    To eloborate a bit more on 'decoding bitfields':

                    - The selections of multiple options are stored in a single (integer) field.
                    - Each new option gets assigned the next power of 2 as a value (so values will be: 1, 2, 4, 8, 16, 32, .......).
                    - The values of all selected options are added together and placed in the integer field.
                    - To check if an option was selected you will need to check if the option value is included in the stored value. Since we are using powers of 2 as the option values, you can do this with a simple bitwise condition.

                    Example, have the following 4 possible options:
                    - Option A (value 1, binary value 1)
                    - Option B (value 2, binary value 10)
                    - Option C (value 4, binary value 100)
                    - Option D (value 8, binary value 1000)

                    If option A & C are selected, the resulting integer will be 5 (1 + 4), and this will be stored. IF you try, you will find out that the value of '5' can only be made by the combination of A & C.

                    Now to test if an option is selected, all you need to do is do a bitwise comparison to see if the option value is included in the stored value.

                    In PHP for example to test for Option C:
                    PHP Code:
                    if ($myintegervalue 4)
                    { ...
                    process... } 
                    Want to take your board beyond the standard vBulletin features?
                    Visit the official Member to Member support site for vBulletin Modifications: www.vbulletin.org

                    Comment


                    • #11
                      No idea if you figured this out, but it goes like this:

                      Code:
                      <td><if condition="$post[field27] != '0'">
                      <if condition="$post['field27']&1">
                      Checkbox #1<br />
                      </if>
                      <if condition="$post['field27']&2">
                      Checkbox #2<br />
                      </if>
                      <if condition="$post['field27']&4">
                      Checkbox #3<br />
                      </if>
                      <if condition="$post['field27']&8">
                      Checkbox #4<br />
                      </if>
                      <if condition="$post['field27']&16">
                      Checkbox #5<br />
                      </if> 
                      <else />
                                      <em>$vbphrase[n_a]</em>
                                  </if></td>

                      Hope it helps someone

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X