EPrints Technical Mailing List Archive

Message: #05956


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [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@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Robin Sylvestre
Sent: 21 September 2016 21:56
To: eprints-tech@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