[Koha-bugs] [Bug 12404] CSV profiles improvements

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Nov 4 13:54:47 CET 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12404

--- Comment #17 from Frédéric Demians <frederic at tamil.fr> ---
> I am not sure to understand the problem.
> In our case (CSV), you will set something like:
> ===
> Title=[% FOREACH field IN fields.245 %][% field.a.0 %] [% field.a.n %] [%
> field.a.p %] [% field.a.h %] [% field.a.b %][% END %]
> ===
> 
> Since it's not possible to display an entire field and you need to list the
> subfields you want to display, the order is not a problem.

Let suppose than another valid 245 field contains (from LoC MARC21 format):

245 00 $a Love from Joy :
       $b letters from a farmer’s wife.
       $n Part III,
       $p 1987-1995, At the bungalow.

It must be displayed (and exported): Love from Joy : letters from a farmer’s
wife. Part III, 1987-1995, At the bungalow.

With you TT (minus typo): Love from Joy : Part III, 1987-1995, At the bungalow.
letters from a farmer's wife.

You can't have an unique TT for all 245 subfields combinations.

> IMO this way allows us a very good flexibility (since we can use the TT
> methods) with a minimum of code.

It still possible. Fields order isn't that important, but sufields is. You
could build an hashref of arrayref of arrayref. For a $record containing a
MARC::Record (its a variation of your code):

my $fields;
for my $field ( $record->fields ) {
    my $fieldtag = $field->tag;
    my $values;
    if ( $field->is_control_field ) {
        $values = $field->data();
    } else {
        $values->{indicator}{1} = $field->indicator(1);
        $values->{indicator}{2} = $field->indicator(2);
        for ( $field->subfields ) {
            my ($letter, $value) = @$_;
            push @{ $values->{subf} }, [ $letter => $value ];
        }
    }
    # We force the key as an integer (trick for 00X and OXX fields)
    push @{ $fields->{fields}{0+$fieldtag} }, $values;
}

And then to display the first 245 field, all subfields in order:

[% FOREACH s IN fields.245.first.subf %][% s.1 %] [% END %]

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list