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

[EP-tech] Quick export plugin question



Hi Robin,
This example is from EPrints::Plugin::Export::DC:

if( $eprint->exists_and_set( "subjects" ) )
{
                my $subjectid;
                foreach $subjectid ( @{$eprint->get_value( "subjects" )} )
                {
                        my $subject = EPrints::DataObj::Subject->new( $plugin->{session}, $subjectid );
                        # avoid problems with bad subjects
                                next unless( defined $subject );
                        push @dcdata, [ "subject", EPrints::Utils::tree_to_utf8( $subject->render_description() ) ];
                }
}

The reason this is a bit more complex than just outputting the value is that the subjects can be multi-lingual, so there is a translation from the stored value to the ?human? version in a specific language (even if you?re not using them!) ? based on the language used for the session.

How should $data->{B} be constructed when there are multiple subjects?
The ?push @dcdata? line should be changed to do whatever you need ? maybe constructing a string that is then assigned to $data->{B}.

Cheers,
John



From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Robin Sylvestre
Sent: 21 September 2016 21:56
To: eprints-tech at ecs.soton.ac.uk
Subject: [EP-tech] Quick export plugin question

Hello everyone,

I?m wondering if someone could help me here. Using an export plugin, I would like to export a value from a subject tree.

Currently, the code is:

$data->{B} = $dataobj->get_value( "divisions" ) if $dataobj->exists_and_set( "divisions" );

This works, but it exports the ?subject ID string? rather than the rendered subject.

How can I export the associated subject instead of the ID? Our archive is multilingual but these ?subjects? are in only one language.

Thanks!

[Image removed by sender. http://www.polymtl.ca/sc/img/logoType/logoseul/gauche/polytechnique_gauche_cmyk.jpg]
Robin Sylvestre
Technicien en documentation
Services techniques et syst?mes informatis?s
Biblioth?que Louise-Lalonde-Lamarre
?cole Polytechnique de Montr?al
T?l.: 514-340-4711 poste 3743
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160922/ab6e84c3/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 513 bytes
Desc: image001.jpg
Url : http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160922/ab6e84c3/attachment-0001.jpg