deadmouse Posted October 18, 2011 Report Share Posted October 18, 2011 How would I go about hiding custom profile fields based on a certain value. So I have a field which says if they have admin on a gaming server. If the field for either Server 1 or Server 2 = Yes then I want it to be displayed but if the fields are both blank then they arent displayed at all. Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 19, 2011 Management Report Share Posted October 19, 2011 As far as I can see if a custom field doesn't have a value it shouldn't show in the topic or profile views. Is this a dropdown custom field you have setup? If so what's the value for empty, or do you just have Server 1 and 2 as options? Quote Link to comment Share on other sites More sharing options...
deadmouse Posted October 19, 2011 Author Report Share Posted October 19, 2011 (edited) How exactly should I set this blank value? I have tried using = No no= =No All of which still cause it to be displayed. Edited October 19, 2011 by deadmouse Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 19, 2011 Management Report Share Posted October 19, 2011 Try. 0=No Edit: Ok that might now work, is this the only custom field you've got?, might be easier to modify the template bit. Quote Link to comment Share on other sites More sharing options...
deadmouse Posted October 19, 2011 Author Report Share Posted October 19, 2011 That doesn't work either. I guess I will just have to modify the template file. Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 19, 2011 Management Report Share Posted October 19, 2011 Might not be able to do it through a template edit, it looks like it loads the full text for displaying the custom field rather then the field id and value. I haven't tested this much but try this edit. Open ips_kernal/classCustomFields.php Find: (around line 650) if( in_array( trim( $value[0] ), $curr_values ) ) Add ABOVE: if( !$value[0] ) { continue; } Save ips_kernal/classCustomFields.php. This should now skip any fields with an empty value. Quote Link to comment Share on other sites More sharing options...
deadmouse Posted October 19, 2011 Author Report Share Posted October 19, 2011 (edited) I not only want to cut out the empty field but if both fields are empty I want to cut that whole section out. This is the code I have so far but have been having issues getting it to work. The custom field groups reference is "server_admin" and the members groups that I want to display the group are 4, 11 and 13. <if test="$group = 'server_admin'"> <if test="IPSMember::isInGroup( $this->memberData, array( 4,11,13 ) )"> <div class='general_box clearfix' id='custom_fields_{$group}'> <h3 class='bar'>{$member['custom_field_groups'][ $group ]}</h3> <ul class='ipsList_data clearfix'> <foreach loop="pcfieldsOtherLoopCheckInner:$member['custom_fields'][ $group ] as $key => $value"> <li>{$value}</li> </foreach> </ul> </div> </if> <else /> <div class='general_box clearfix' id='custom_fields_{$group}'> <h3 class='bar'>{$member['custom_field_groups'][ $group ]}</h3> <ul class='ipsList_data clearfix'> <foreach loop="pcfieldsOtherLoopCheckInner:$member['custom_fields'][ $group ] as $key => $value"> <li>{$value}</li> </foreach> </ul> </div> </if> I'm guessing this isn't working becasue of the first if statement but I can't work it out. Edited October 19, 2011 by deadmouse Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 20, 2011 Management Report Share Posted October 20, 2011 Are you setting up $group as a variable or do you want to only load if the $group variable has the value server_admin? If the later, you'll need to modify your first line a bit. <if test="$group == 'server_admin'"> Quote Link to comment Share on other sites More sharing options...
deadmouse Posted October 20, 2011 Author Report Share Posted October 20, 2011 (edited) Well I added the double == but it still isn't working :( *edit* After some testing it seems this isn't working correctly IPSMember::isInGroup( $this->memberData, array( 4,11,13 ) ) No clue how to fix it tho lol. Edited October 20, 2011 by deadmouse Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 20, 2011 Management Report Share Posted October 20, 2011 Well the isInGroup function should support either the member_id or an array like you have, so don't see any problem there. Just to confirm you want to show it to the member viewing the page or the members custom fields your displaying? Quote Link to comment Share on other sites More sharing options...
deadmouse Posted October 20, 2011 Author Report Share Posted October 20, 2011 (edited) Members profile, not the person viewing it. I can see what I did wrong. *edit* I changed $this->memberData to $member and now its working great. Thanks for the help. Edited October 20, 2011 by deadmouse Quote Link to comment Share on other sites More sharing options...
Management Michael Posted October 20, 2011 Management Report Share Posted October 20, 2011 No problem. :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.