When creating a view, and selecting options:

"Last name only" works fine, but "First name only" does not.

There was an error in the code near line 749 where

$cck_fullname['first_preferred'] was set, but ['first'] is used in the output so no first name ever shows up.

Also, isset() was used where !empty() would probably be more appropriate. It looks like ['first_preferred'] keys are set, even if they are blank.

The fix is below... not sure how to submit patch.

Existing code

   case 'last_name_only'://output legal last name
      //check and clean the values for output
        if (isset($item['last'])) {
          $cck_fullname['last'] = strip_tags($item['last']);
        }
        $output .= theme('cck_fullname', $cck_fullname, $field);
      return $output;
    case 'first_name_only'://output preferred first name
      //check and clean the values for output
        if (isset($item['first_preferred'])) {
          $cck_fullname['first_preferred'] = strip_tags($item['first_preferred']);
        }
        $output .= theme('cck_fullname', $cck_fullname, $field);
      return $output;

Fixed Code

   case 'last_name_only'://output legal last name
      //check and clean the values for output
        if (!empty($item['last'])) {
          $cck_fullname['last'] = strip_tags($item['last']);
        }
        $output .= theme('cck_fullname', $cck_fullname, $field);
      return $output;
    case 'first_name_only'://output preferred first name
      //check and clean the values for output
        
        if(!empty($item['first'])) {
          $cck_fullname['first'] = strip_tags($item['first']);
        }
        if (!empty($item['first_preferred'])) {
          $cck_fullname['first'] = strip_tags($item['first_preferred']);
        }
        $output .= theme('cck_fullname', $cck_fullname, $field);
      return $output;
CommentFileSizeAuthor
#5 cck_fullname_p2.diff1.44 KBnasi
#4 cck_fullname.diff1.36 KBwebmasterkai

Comments

rconstantine’s picture

Firstly, FYI Drupal etiquette is that a poster doesn't mark his/her own patch as "ready to be committed" since a lot of factors could mean that it isn't. Fortunately in this case, you identified the fact that the preferred first name should take precedence over the legal name for display purposes (although a legal first option could be added), and you correctly overwrite it if it is set.

So yes, this looks ready to be committed. Thanks for the code. [I haven't used all of these features myself, so I appreciate it when someone who needs them is able to correct them.]

I'm still open to any other help that would make this module work better with Views if you know how to do it.

Will try to get another release out soon...?

frankcarey’s picture

my bad... (my first patch).. thanks for the heads up.

Petra’s picture

Fortunately in this case, you identified the fact that the preferred first name should take precedence over the legal name for display purposes (although a legal first option could be added), and you correctly overwrite it if it is set.

This is inconsistent for me. Preferred name has the same fields als legal name. So why take preferred first, when it's called first name.
Please add a legal first option.

I tried the code - it works, but in a talbe view the column for "First name only" will be sorted in order of "Last name only". "Last name only" sorts the names correct. Any idea how to fix this?

webmasterkai’s picture

StatusFileSize
new1.36 KB

Patch works for me.

nasi’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.44 KB

I've just found this issue having come across the same problem and written my own fix!

My patch is very similar to the one already submitted, in that I made the same assumption that a preferred name (if present) should be shown in preference to a legal name. However, I also applied that same logic to the display of the last name and my code logic doesn't perform redundant operations if both names are present.

As for the sorting, I think that would require deeper integration with Views - at least to add further options to the fullname sort criteria.

rconstantine’s picture

I'll leave this active for those who might still be using the D5 version since I never got around to adding this patch myself. Shame on me.

alan d.’s picture

Status: Needs review » Closed (outdated)

Closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.