This patch adds options to expose to views the following,

-First middle and last
-first name only
-last name only

This would allow users to have more sort options, and more display options, without changing the workings of each individual instance of the field.

Please see http://lists.drupal.org/pipermail/support/2007-July/005189.html for an example of why this might be needed

Comments

mikey_p’s picture

On further review...perhaps there should be a view option for

'First Middle Last' (Will default to 'First Last' when middle is not present or disabled)
'Last, First Middle' (Will default to 'Last, First' when middle is not present or disabled)
'First'
'Last'

Any other formats that should be included? Or should this all be done with themeing?

mikey_p’s picture

Actually, formatting it as "Last, First Middle" would require a different theme function to do most optimally, however it would seem to be nice to be able to do this as a per view option.

mikey_p’s picture

Hrm, so I don't know if this is a views or cck issue, but formatters are not exposed as sort criteria to views. Only the default, provided in hook_field, op 'view' is sortable in the sort criteria area.

One way to get around this would be to make an option in the field settings to choose the default formatter. This won't really affect everyday use of the field, because I *believe* that everywhere it is displayed there exists the option to choose the desired formatter. (such as the display tab under edit for each content type, or the fields section of a view)

By setting the default formatter to 'last name only', or 'last, first middle', there exists that the ability to select which is used for sort criteria in views. However this is rather kludgy, since it requires changing what would appear to be a totally unrelated setting to get the desired effect.

mikey_p’s picture

StatusFileSize
new4.23 KB

Here's a patch that adds 'Last, first middle' as a format, and adds a parameter to be passed to the theme function to tell it how to render that

rconstantine’s picture

Cool. I'll review this the first chance I get!

Two messages ago you asked:

Hrm, so I don't know if this is a views or cck issue, but formatters are not exposed as sort criteria to views.

I read somewhere that it is a CCK issue because the author(s) didn't account for modules like cck_address and cck_fullname where multiple fields are rolled into one. Does your patch change the default formatter as you suggested? Or was that an exercise to do at a later time? As I recall, that won't actually change the sort field. What the view sorts is the first entry in the

  case 'database columns':
      $columns = array(
        'value' => array('type' => 'varchar', 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
        'format' => array('type' => 'int', 'length' => 10, 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
      );

of the hook_field_settings function. [this code was taken from the text.module] You'll notice that all of the 'standard' cck modules label the first item as 'value'. This is what is expected to be the sortable part. It is my understanding that although the first item doesn't require the label to actually be 'value', that it is still the only one used for sorting in views.

rconstantine’s picture

Assigned: Unassigned » rconstantine
Status: Needs review » Reviewed & tested by the community

So I quickly took a look at your patch in my browser and it all looks fine to me. Like I said, I think this will only change the display and not the sort field. I think either I opened an issue over at CCK at some point a couple of months ago, or I commented on an existing one. Feel free to tackle that issue over there. I'm in the middle of a 'handshake' module and the final touches on the new 'og_forum' module, so can't look more into cck myself at the moment.

mikey_p’s picture

Thanks for taking a look at this, obviously I didn't get to changing the default part, and I guess it's as good that I didn't because I don't really understand CCK/Views internals all that well. I very briefly chatted about this with merlin the other day, and he seemed to think it was a CCK issue, and I think I see why now, thanks to your follow up.

rconstantine’s picture

Did you get this to work? I'm having trouble with this. When I produce a view that uses one fullname field for the field, shown as a table or list via a page view (paginated or not), limit set to either 10 or 0, I get a bunch of empty entries followed by the actual expected results. I'm using the latest official views and cck releases.

I see that there is a 'filter' section of the cck_fullname_field_settings function. Perhaps something needs to be added there?

This: http://drupal.org/node/106716 is the best documentation I can find. I'm not seeing any other modules I have that are helping me figure this part out. Is it even needed?

rconstantine’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new6.33 KB

Attached is a patch with both your and my changes. Try and see if you can get it to work.

rconstantine’s picture

Are you interested or not?

rconstantine’s picture

Status: Needs work » Closed (fixed)

Guess not, but I added the change anyway. Was included in the last release.