[EP-tech] Re: Modifying compound fields with eprint_fields_automatic
sf2
sf2 at ecs.soton.ac.uk
Fri Oct 17 16:31:48 BST 2014
Hola Lizz,
I would do something like:
my $creators = @{ $eprint->value( 'creators' ) || [] };
...
push @newcreators, { name => ... , etc };
...
in your example you push an array-ref onto the array rather than pushing
a single record/row:
push @foo, [ { ... } ] vs push @foo, { ... }
Seb
On 17.10.2014 16:33, Lizz Jennings wrote:
> Hi all,
>
> I'm getting in a bit of a tangle.
>
> I'd like to be able to add a function to eprint_fields_automatic for the
> creators field to generate affiliation information based on email
> addresses (where it's obvious e.g. academic institutions). I've hit a
> stumbling block immediately - I can't seem to get this to work without
> overwriting the whole thing with a single row (I've managed several
> variations on this particular theme).
>
> This currently works to overwrite the whole list with the first creator
> and does add in or change the affiliation.
>
> if ( $type eq "data_collection" ) {
> my $creators = $eprint->get_value( "creators" );
> my @newcreators;
> foreach my $creator (@$creators) {
> push @newcreators, [{ name => $creator->{name}, id =>
> $creator->{id}, orcid => $creator->{orcid}, affiliation => "bibble",
> contact => $creator->{contact} }];
> }
> $eprint->set_value( "creators", @newcreators );
>
> }
>
> Any ideas on how to do this properly would be much appreciated.
>
> Lizz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20141017/013c1a63/attachment.html
More information about the Eprints-tech
mailing list