Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Using Internal IDs for Staff Browse Views
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Add Internal ID to creators/editors/contributors fields for an EPrint === 1. Add the following code the a file at '''/opt/eprints3/lib/plugins/EPrints/MetaField/Internalidname.pm''': package EPrints::MetaField::Internalidname; use strict; use warnings; use EPrints::MetaField::Text; BEGIN { our( @ISA ); @ISA = qw( EPrints::MetaField::Text ); } sub _get_name { my( $self, $session, $internalid ) = @_; my $format = $session->config( 'internalid_to_name', 'format' ); return unless defined $format; if( $session->can_call( 'internalid_to_name', 'parser' ) ) { my $name = $session->call( [ 'internalid_to_name', 'parser' ], $session, $internalid ); return $session->render_name( $name, $format ) if defined $name; } return; } sub get_value_label { my( $self, $session, $value ) = @_; my $name = $self->_get_name( $session, $value ); return $name if defined $name; return $session->make_text( $value ); } sub ordervalue_basic { my( $self, $value, $session, $langid ) = @_; my $name = $self->_get_name( $session, $value ); return EPrints::Utils::tree_to_utf8( $name ) if defined $name; return $value; } sub render_single_value { my( $self, $session, $value ) = @_; return $self->get_value_label( $session, $value ); } 1; 2. Edit your archive's '''cfg/cfg.d/eprint_fields.pl'''. Under the field named '''creators''', you will see a block labelled '''fields'''. Copy and paste the block that has the '''sub_name''' '''id''' and copy and paste it just before the end '''fields''' block, ensuring to add a comma a comma prior to this. Then modify the '''sub_name'' from '''id''' to ''internalid'''. The creators block should then look something like below: { 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, }, { sub_name => 'internalid', type => 'internalidname', input_cols => 10, allow_null => 1, render_single_value => 'render_internalid', }, ], }, 3. Repeat this change with the '''contributors''' and '''editors'' fields. 4. Create a file called '''internalid_to_name.pl''' in '''cfg/cfg.d/''' of your archive, with the following contents: $c->{internalid_to_name}->{parser} = sub { my( $session, $internalid ) = @_; return unless EPrints::Utils::is_set( $internalid ); my $user_ds = $session->get_repository->get_dataset( "user" ); my $user_search = new EPrints::Search( session => $session, dataset => $user_ds ); $user_search->add_field( $user_ds->get_field( "internalid" ), $internalid ); my $users = $user_search->perform_search; return unless $users->count() > 0; return $users->item( 0 )->get_value("name"); }; $c->{internalid_to_name}->{format} = 0; # family, given $c->{render_internalid} = sub { my( $session, $field, $value, $obj ) = @_; my $fragment = $session->make_doc_fragment; $fragment->appendChild($session->xml->create_text_node($value)); return $fragment; } 5. Run EPrints database update command to add these new sub-fields: /opt/eprints3/bin/epadmin update ARCHIVENAME 6. Assuming the above has been successful add the phrases required for this new field to '''cfg/lang/en/phrases/local.xml''' <epp:phrase id="eprint_fieldname_creators_internalid">Internal ID</epp:phrase> <epp:phrase id="eprint_fieldhelp_creators_internalid">Unique ID used to identify a user, used by <epc:phrase ref="archive_name" /></epp:phrase> <epp:phrase id="eprint_fieldname_contributors_internalid">Internal ID</epp:phrase> <epp:phrase id="eprint_fieldhelp_contributors_internalid">Unique ID used to identify a user, used by <epc:phrase ref="archive_name" /></epp:phrase> <epp:phrase id="eprint_fieldname_editors_internalid">Internal ID</epp:phrase> <epp:phrase id="eprint_fieldhelp_editors_internalid">Unique ID used to identify a user, used by <epc:phrase ref="archive_name" /></epp:phrase> 7. Test that EPrints is happy with these changes and if so reload Apache: /opt/eprints3/bin/epadmin test ARCHIVENAME apachectl graceful
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)