[Rt-devel] Minor bug/patch in search results - multi-value CFs

Stephen Turner sturner at MIT.EDU
Tue Dec 21 11:31:47 EST 2004


Minor bug - in search results, a custom field with multiple values is shown 
with its values concatenated (e.g. "AppleOrangeBanana").

Here's a suggested small patch that would comma-separate the list.

I replaced the map statement with a loop to give this part more flexibility 
- I could imagine adding something extra in the future to handle 
multi-value image custom fields differently  - you may not want a comma 
separated list of images.

The patch applies to 3.3.12. The first part of the patch can be ignored - I 
applied a bug fix that appears in 3.4.0rc1 to my code.

Steve


% diff -u share/html/Elements/CollectionAsTable/Row 
local/html/Elements/CollectionAsTable/Row
--- share/html/Elements/CollectionAsTable/Row   2004-11-09 
03:28:53.000000000 -0500
+++ local/html/Elements/CollectionAsTable/Row   2004-12-21 
11:18:27.000000000 -0500
@@ -58,7 +58,7 @@
  foreach my $column (@Format) {
      if ( $column->{title} eq 'NEWLINE' ) {
         while ($item < $maxitems) {
-           $m->out('<td class="collection-as-table">>&nbsp;</td>\n');
+           $m->out(qq{<td class="collection-as-table">&nbsp;</td>\n});
             $item++;
         }
         $item = 0;
@@ -78,10 +78,13 @@
                 # All HTML snippets are returned by the callback function
                 # as scalar references.  Data fetched from the objects are
                 # plain scalars, and needs to be escaped properly.
-               $m->out(
-                   map { ref($_) ? $$_ : $m->interp->apply_escapes( $_ => 
'h' ) }
-                   &{ $value } ( $record, $i )
-               );
+               my @vals =  &{ $value } ( $record, $i );
+               my $i=0;
+               foreach my $val (@vals) {
+                   $m->out(", ") if $i > 0; # separator for multi-value fields
+                   $m->out(ref($val) ? $$val : $m->interp->apply_escapes( 
$val => 'h' ));
+                   $i++;
+               }
              } else {
                 # Simple value; just escape it.
                  $m->out( $m->interp->apply_escapes( $value => 'h' ) );  



More information about the Rt-devel mailing list