function fp_push_and_balance_profile_items

7.x theme.inc fp_push_and_balance_profile_items(&$profile_items, array $item)
6.x theme.inc fp_push_and_balance_profile_items(&$profile_items, array $item)

This function accepts a "profile items" array by reference, which is presumed to have a "left_side" and a "right_side" already defined. We can "push" items onto it, and the item will automatically go to the side with the fewest "items" so as to keep it "balanced."

1 call to fp_push_and_balance_profile_items()
user_alter_student_profile_items in modules/user/user.module
Implements hook_alter_student_profile_items

File

includes/theme.inc, line 798

Code

function fp_push_and_balance_profile_items(&$profile_items, array $item) {

  // We do the -1 to the right_side, because it is already unbalanced by 1 as a default.
  $dec = 1;

  if (count($profile_items ['right_side']) == 0) {
    $dec = 0;
  }

  if (count($profile_items ['left_side']) <= count($profile_items ['right_side']) - $dec) {
    $profile_items ['left_side'] += $item;
  }
  else {
    $profile_items ['right_side'] += $item;
  }

  // No need to return, since passed by reference.

}