Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/26/2011 05:26:30 PM (14 years ago)
Author:
boonebgorges
Message:

Adds hide_empty_fields parameter to bp_has_profile() and the rest of the profile template chain, to make zebra striping easier in the profile component. Fixes #3074. Props johnjamesjacoby for help with the patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-template.php

    r4840 r4869  
    2121    var $user_id;
    2222
    23     function bp_xprofile_data_template( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false ) {
    24         $this->__construct( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields );
    25     }
    26 
    27     function __construct( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false ) {
     23    function bp_xprofile_data_template( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false, $hide_empty_fields = false ) {
     24        $this->__construct( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields, $hide_empty_fields );
     25    }
     26
     27    function __construct( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false, $hide_empty_fields = false ) {
    2828        $this->groups = BP_XProfile_Group::get( array(
    2929            'profile_group_id'  => $profile_group_id,
    3030            'user_id'           => $user_id,
    3131            'hide_empty_groups' => $hide_empty_groups,
     32            'hide_empty_fields' => $hide_empty_fields,
    3233            'fetch_fields'      => $fetch_fields,
    3334            'fetch_field_data'  => $fetch_field_data,
     
    153154    global $bp, $profile_template;
    154155
     156    // Only show empty fields if we're on the Dashboard, or on a user's profile edit page
     157    $hide_empty_fields = ( !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() );
     158
    155159    $defaults = array(
    156160        'user_id' => $bp->displayed_user->id,
    157161        'profile_group_id'  => false,
    158162        'hide_empty_groups' => true,
     163        'hide_empty_fields' => $hide_empty_fields,
    159164        'fetch_fields'      => true,
    160165        'fetch_field_data'  => true,
     
    166171    extract( $r, EXTR_SKIP );
    167172
    168     $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields );
     173    $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields, $hide_empty_fields );
    169174    return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template );
    170175}
     
    190195    function bp_get_field_css_class( $class = false ) {
    191196        global $profile_template;
    192 
     197       
    193198        $css_classes = array();
    194199
Note: See TracChangeset for help on using the changeset viewer.