Minor bug/patch in search results - multi-value CFs

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' ) );

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.

So, sometimes we use commas and sometimes we use

    lists. I’m sort of
    tempted to standardize on the lists since they’re something that’s
    somewhat easier to parse. (What happens if you have values with
    embedded commas). Thoughts?
Jesse

At Tuesday 12/21/2004 02:56 PM, Jesse Vincent wrote:>On Tue, Dec 21, 2004 at 11:31:47AM -0500, Stephen Turner wrote:

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.

So, sometimes we use commas and sometimes we use

    lists. I’m sort of
    tempted to standardize on the lists since they’re something that’s
    somewhat easier to parse. (What happens if you have values with
    embedded commas). Thoughts?
    Jesse

Agreed, the commas don’t quite do it. The UL lists look OK and do match the
ticket display screen. Should I send something in to do this?

Steve