The following patch adds a new option called "First and last only" to the Multiple field settings. The new setting behaves well with the other settings in that section (separator, limit, offset, and reverse). It is useful, for example, to display only the first and last dates of a repeating event.

Comments

rlhawk’s picture

StatusFileSize
new0 bytes

Patch attached.

rlhawk’s picture

StatusFileSize
new3.01 KB

Take 2.

rlhawk’s picture

Status: Active » Needs review
PedroMiguel’s picture

Got this error:

Notice: Undefined variable: delta_first_last em views_handler_field_field->get_value() (linha 728 de /home/*****/public_html/drupal/sites/all/modules/views/modules/field/views_handler_field_field.inc).
Notice: Undefined variable: delta_first_last em views_handler_field_field->get_value() (linha 728 de /home/******/public_html/drupal/sites/all/modules/views/modules/field/views_handler_field_field.inc).

Details:

taxonomy term with:
- Multiple field settings
- Display all values in the same row checked
- Simple separator

dawehner’s picture

Status: Needs review » Needs work

Based on #4 update status

+++ b/modules/field/views_handler_field_field.incundefined
@@ -708,7 +726,10 @@ class views_handler_field_field extends views_handler_field {
+          if (! $delta_first_last || $new_delta == $offset || $new_delta == $delta_limit - 1) {
+	          $new_values[] = $all_values[$new_delta];

You probably assume here that there is always at least a second value.

rlhawk’s picture

Status: Needs work » Needs review
StatusFileSize
new3.21 KB

Replacement patch to fix error in #4.

rlhawk’s picture

StatusFileSize
new3.22 KB

I just noticed a situation where first-last would not play nicely with offset. Fixed and new patch attached.

dawehner’s picture

Status: Needs review » Fixed

Thanks this patch looks fine now, commited with some minor changes.

Commited to 7.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.