Modification Request: Allow members to select what is shown in their postbit.

Discussion in 'vBulletin Discussions' started by Tyler, May 30, 2009.

  1. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    I am looking for a mod to let a member choose what is shown in their postbit via their user control panel (edit profile or options). They should be able to choose to show or hide their avatar, post count, join date, location, and custom profile field A/B/C/etc. Attached is a screenshot of a forum that actually has this.

    If you know a mod that does this or a way to do it, it would be greatly appreciated.
     
  2. Ryan

    Ryan Regular Member

    Joined:
    May 27, 2009
    Messages:
    522
    Likes Received:
    58
    If statements?

    Like staff can do that on my board. They can remove avatars.

    When they register or edit options they can tick the option, then on the postbit there is a IF statement about not showing the avatars if the box is checked.
     
  3. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    This is fairly simple to do 'by hand'... just like I've done here to allow members to re-add the New Posts link to the navbar.
     
  4. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    No, just like the screenshot. Like, to show their own items. For example, if they have everything unchecked all you would see is a username in the postbit.

    I know, and yet I still cannot do it. This is my weak area. :(
     
  5. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    So are you wanting a tutorial?
     
  6. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    Yeah, if you know how I can do this, I'd really love the help.
     
  7. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    Alright, I'll see what I can work up. :)
    I know I can do it, I just need to gather the patience to sit and write a small guide/tutorial. :p
     
  8. ArnyVee

    ArnyVee Regular Member

    Joined:
    May 25, 2009
    Messages:
    1,264
    Likes Received:
    39
    I would love to see this as well :)
     
  9. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    Wow. :doh:

    I just realized that I misread your post and therefore incorrectly assumed I knew what you were wanting. I thought that you wanted to allow users to control what they see in all other users' postbit, when in fact you are wanting to allow them to control what other members see in their postbit.

    This is a toughie - maybe Wayne can chime in. :)
     
  10. Chris

    Chris Regular Member

    Joined:
    Dec 27, 2007
    Messages:
    5,422
    Likes Received:
    86
    Shame on you, Nick.
     
  11. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    Yeah, it stinks really. I spent a good thirty minutes writing the tutorial on how to do what I thought was wanted. Right after I posted it, I realized my mistake. :doh:
     
  12. Lynne

    Lynne Regular Member

    Joined:
    May 26, 2009
    Messages:
    333
    Likes Received:
    32
    Location:
    Home Sweet Home!
    I'm guessing it's very much the same sort of thing. In one case you are looking at $bbuserinfo[fieldx] and in the other case you are looking at $post[fieldx].
     
  13. Nick

    Nick Regular Member

    Joined:
    Jul 27, 2008
    Messages:
    7,441
    Likes Received:
    218
    Lynne, I thought so but I didn't take the time to think it through or test it. I guess I can post the tutorial I had and just refer to your change - whoever is willing can give it a try.

    Here it is:

    I'm just going to briefly describe most of the steps because I don't think we need baby steps all the way through. But let me know if you need additional direction.

    Firstly, you need to create a new custom profile field. I'm going to go by what's in the screenshot you referred to in your original post.
    The profile field needs to be a "Multiple-Selection Checkbox". The first few options are to be decided by you. I'd leave the Limit Selection at zero, and change the Items Per Line to '1'.
    In the options box, list all of the things you'd like to control (one per line): Avatar, Join Date, Location, Post Count, etc. Take note of the order you listed these options.
    The rest of the options can be configured at your discretion.

    Once you create the field, you are taken to the page listing all of your custom profile fields - be sure to take note of the ID of the one you just created. You will need this in the next step.

    Now the fun part: editing the postbit or postbit_legacy template (whichever one you use).

    I don't think I need to provide instructions for each element, so I'll just start with the first one on our selection list - the avatar.

    In the template, find:
    Code:
    <if condition="$show['avatar']">
    <table align="center" cellpadding="5" cellspacing="0" style="border: 1px solid #d6e7ea; background: #fff;">
    <tr>
    <td valign="top"><div><a rel="nofollow" href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
    </div></td></tr></table>
    </if>
    In our example, the avatar control is the first (1) option, so we are going to place this conditional above the aforementioned code:
    Code:
    <if condition="$bbuserinfo['field[B][COLOR=Red]X[/COLOR][/B]'] & [COLOR=Blue][B]1[/B][/COLOR]">
    
    .... and place </if> right after the avatar code from above.
    Be sure to change the red X to the number of the field ID (which you noted when you created the field)

    This conditional essentially says, "if the user ticked the first option (show avatar) in field X, then proceed".

    You will find the appropriate code (in the template) for each element you wish to be controlled by users and wrap the appropriate conditional around it. The only thing you will change each time is a small part of the conditional used: (the field ID, obviously, AND) the number at the end of the conditional (right after the ampersand; in blue in our above example).
    For the first option, you use 1 (just as in our avatar-control example).
    For the second, you will use 2.
    For the third, you will use 4.
    4th option = 8
    5th option = 16
    6th option = 32
    ... and so on. I think you see the pattern of multiplying by two for each increment.

    I think this covers everything. Let me know if you need further explanation or any help.

    Considering the circumstances and misunderstanding mentioned above, I'm not sure if this will do exactly as is wanted. But give it a try...
     
  14. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    I appreciate the help, but although it was pretty close, there were a few problems I encountered.

    1) I am using a background behind the postbit info like we have here. When something is unselected, there will still be a box there but with no text inside of it.

    2) Like you said it would, this is changing what I see for everyone, not just what is seen for myself.
     
  15. Lynne

    Lynne Regular Member

    Joined:
    May 26, 2009
    Messages:
    333
    Likes Received:
    32
    Location:
    Home Sweet Home!
    Nick, you need to change $bbuserinfo to $post. $bbuserinfo refers to the person viewing the page. $post refers to the person who posted.

    Also, put the condition around the whole thing (like the whole table to show the avatar), not just the variable itself.
     
  16. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    Thank you, Lynne. It is just about perfect now, with one more problem unrelated to this edit:

    Like AA, I have a background behind the postbit info. Depending on what I am hiding, the background will either go away, work right, or have a blank bar.

    Attached will be screenshots with me hiding posts/join date/and location. You can see the unexpected changes it is making for some reason.
     
  17. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    Here is my sloppy code and one more screenshot:

    PHP:
    <if condition="$post['field5'] & 1"><if condition="$show['avatar']">
    <
    table align="center" cellpadding="6" cellspacing="0" style="border: 1px solid #5b5b5b; background: #fff;">
    <
    tr>
    <
    td valign="top"><div><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]$post[avwidth$post[avheightalt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
    </
    div></td></tr></table>
    </if></if>

    <if 
    condition="$post['field5'] & 16"><if condition="$post['usertitle']"><div class="smallfont" align="center">$post[usertitle]</div></if></if>
    <if 
    condition="$post['rank']"><div class="smallfont" align="center">$post[rank]</div></if>

    <if 
    condition="$post['field5'] & 4"><div class="smallfont"><if condition="$post['joindate']"><div>$vbphrase[join_date]: $post[joindate]</div></if></if>
    <
    div class="smallfont">
    <if 
    condition="$post['field5'] & 2">$vbphrase[posts]: $post[posts]</if>
    </
    div>
    <if 
    condition="$post['field5'] & 8"><if condition="$post['field2']"><div class="smallfont">$vbphrase[location_perm]: $post[field2]</div></if></if>
    <if 
    condition="$post['age']"><div>$vbphrase[age]: $post[age]</div></if>
    Code:
    .postdetail div.smallfont div {
    background: #fff;
    margin: 2px 1px;
    border-top: 1px solid  #aaa;
    border-right: 1px solid  #5b5b5b;
    border-bottom: 1px solid  #5b5b5b;
    border-left: 1px solid  #aaa;
    padding: 3px;
    font: 8pt verdana, tahoma, verdana, sans-serif;
    }
     
  18. Lynne

    Lynne Regular Member

    Joined:
    May 26, 2009
    Messages:
    333
    Likes Received:
    32
    Location:
    Home Sweet Home!
    Savage_X, in the postbit above, you have this for the posts (which are showing an empty box):
    HTML:
    <div class="smallfont"> 
    <if condition="$post['field5'] & 2">$vbphrase[posts]: $post[posts]</if> 
    </div> 
    You need to put the condition around the div tags also, like this:
    HTML:
    <if condition="$post['field5'] & 2"><div class="smallfont"> 
    $vbphrase[posts]: $post[posts] 
    </div> </if>
    Do similar for any other field you are having the same problem.

    And if you want the css above to apply, you need to add class="smallfont" to the div tag.
     
  19. Tyler

    Tyler The Badministrator

    Joined:
    Dec 23, 2007
    Messages:
    3,079
    Likes Received:
    63
    Location:
    Long Island, NY
    First Name:
    Tyler
    Thanks, that got rid of the empty box. But now I am still left it not showing the box at all like seen in the other screenshots. After I fixed that I went in to check and disabled everything but location. It is still showing without the background when I have it like this for some reason.


    Edit: Nevermind, that was actually just my mistake - I got it. Thanks so much, both of you. :D
     
  20. Lynne

    Lynne Regular Member

    Joined:
    May 26, 2009
    Messages:
    333
    Likes Received:
    32
    Location:
    Home Sweet Home!
    Well, this is incorrect also:
    HTML:
    <if condition="$post['field5'] & 4"><div class="smallfont"><if condition="$post['joindate']"><div>$vbphrase[join_date]: $post[joindate]</div></if></if>
    You have two starting div tags in there which is probably screwing up everything after it.
     

Share This Page