[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Re: citation modification



Ah, it's a compound multiple field.

You need to render creators_name, not creators.  Also, try putting the render_single_value in the name subfield definition -- I'm not sure if it will work off the top of my head, but it makes sense.  I've modified the code below.  Let us know if it works.

I modified eprint_fields.pl:
{
       name => 'creators',
       type => 'compound',
       multiple => 1,
       fields => [
               {
                       sub_name => 'name',
                       type => 'name',
                       hide_honourific => 1,
                       hide_lineage => 1,
                       family_first => 1,
                       render_single_value => 'render_name_with_initials',
               },
               {
                       sub_name => 'id',
                       type => 'text',
                       input_cols => 20,
                       allow_null => 1,
               }
       ],
       input_boxes => 2,
},

I introduced eprint_render_single.pl:
print STDERR "It's Me :)\n";
$c->{render_name_with_initials} = sub
{
       print STDERR "It's You :)\n";
       my( $field, $repo, $value ) = @_;
       my $family = $value->{family};
       my $given = $value->{given};
       return $repo->xml->create_text_node( 'foo' );
}

I used Test.pl
#!/usr/bin/perl -I/opt/eprints3/perl_lib

use strict;
use warnings;
use EPrints;

my $ep = EPrints->new;
my $repo = $ep->repository('b40literatur');

my $eprint = $repo->dataset('eprint')->dataobj(3);

print STDERR EPrints::Utils::tree_to_utf8($eprint->render_value('creators_name'));




--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services



On 13 Oct 2015, at 15:09, Thomas Lauke <th.lauke at arcor.de> wrote:

> Hi Adam,
> 
> there's obviously something wrong, although I think to follow all your instructions :(
> 
> I modified eprint_fields.pl:
> {
>        name => 'creators',
>        type => 'compound',
>        multiple => 1,
>        fields => [
>                {
>                        sub_name => 'name',
>                        type => 'name',
>                        hide_honourific => 1,
>                        hide_lineage => 1,
>                        family_first => 1,
>                },
>                {
>                        sub_name => 'id',
>                        type => 'text',
>                        input_cols => 20,
>                        allow_null => 1,
>                }
>        ],
>        render_single_value => 'render_name_with_initials',
>        input_boxes => 2,
> },
> 
> I introduced eprint_render_single.pl:
> print STDERR "It's Me :)\n";
> $c->{render_name_with_initials} = sub
> {
>        print STDERR "It's You :)\n";
>        my( $field, $repo, $value ) = @_;
>        my $family = $value->{family};
>        my $given = $value->{given};
>        return $repo->xml->create_text_node( 'foo' );
> }
> 
> I used Test.pl
> #!/usr/bin/perl -I/opt/eprints3/perl_lib
> 
> use strict;
> use warnings;
> use EPrints;
> 
> my $ep = EPrints->new;
> my $repo = $ep->repository('b40literatur');
> 
> my $eprint = $repo->dataset('eprint')->dataobj(3);
> 
> print STDERR EPrints::Utils::tree_to_utf8($eprint->render_value('creators'));
> 
> But I got finally for perl Test.pl 
> It's Me :)
> CreatorsEmailFoote, H.W.UNSPECIFIEDLevy, L.H.UNSPECIFIED
> 
> Thus my extra subroutine is never called even after apache's restart and database update?!
> 
> Thanks for any hint
> Thomas
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20151013/82523baf/attachment.html