EPrints Technical Mailing List Archive
Message: #04412
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
[EP-tech] Re: [Solved] Re: [spam?] Re: How to set a field to be multilang
- To: eprints-tech@ecs.soton.ac.uk
- Subject: [EP-tech] Re: [Solved] Re: [spam?] Re: How to set a field to be multilang
- From: George Mamalakis <mamalos@eng.auth.gr>
- Date: Tue, 30 Jun 2015 18:39:41 +0300
OK, it's done.
I'll upload the procedure on the wiki when I finish with my project (it'll be after the summer) or if I find free time in the meantime. The general steps are (in order to replace the title field in this example): 1) Create a MetaField which returns a value ( ~eprints/lib/plugins/EPrints/MetaField/Virtualwithvalue.pm) containing the code found in Adam's video: package EPrints::MetaField::Virtualwithvalue; use strict; use warnings; use EPrints::MetaField; our @ISA = qw( EPrints::MetaField ); use strict; sub get_property_defaults { my ( $self ) = @_; my %defaults = $self->SUPER::get_property_defaults; $defaults{get_value} = undef; return %defaults; } sub get_value { my( $self, $object ) = @_; if ( defined $self->get_property("get_value") ) { return $self->call_property( "get_value", $object); } return undef; } 2) Change ./archives/myarchive/cfg/cfg.d/eprint_fields.pl to contain the new fields (ml_title and the new title field (which is based on our newly created MetaField derivative)), ie: { name => 'ml_title', type => 'multilang', multiple => 1, fields => [ { sub_name => "text", type => "longtext", input_rows => 3, make_single_value_orderkey => 'EPrints::Extras::english_title_orderkey' } ], input_add_boxes => 1, }, { name => 'title', type => 'virtualwithvalue', virtual => 1, get_value => sub { my ($eprint) = @_; if ($eprint->is_set('ml_title')) { my $vals = $eprint->get_value('ml_title'); my $title = ''; # set the default lang's text as title foreach my $v1 (@{$vals}) { if (%$v1{'lang'} eq $c->{defaultlanguage}) { $title = %$v1{'text'}; } } # if not a default lang found, get the first object's text as title if ($title eq '') { $title = ${$$vals[0]}{'text'} ; } return $title; } return undef; } }, 3) Update your archive in order to create the new field: $ ./bin/epadmin update myarchive 4) Add the appropriate phrases in ~/archives/myarchive/cfg/lang/en/phrases/local.xml (and do it for any other language you may have): <!-- multilang title related phrases --> <epp:phrase id="eprint_fieldname_ml_title">Title</epp:phrase> <epp:phrase id="eprint_fieldname_ml_title_text">Text</epp:phrase> <epp:phrase id="eprint_fieldname_ml_title_lang">Language</epp:phrase> <epp:phrase id="eprint_fieldhelp_ml_title">The title of the item. The title should not end with a full stop, but may end with a question mark. There is no way to make italic text, please enter it normally. If you have a subtitle, it should be preceded with a colon [:]. Use capitals only for the first word and for proper nouns. <br/>Example: <span class="ep_form_example">A brief history of time</span> <br/>Example: <span class="ep_form_example">Life: an unauthorised biography</span> <br/>Example: <span class="ep_form_example">Mathematics for engineers and scientists. 5th edition</span> <br/>Example: <span class="ep_form_example">Ecosystems of the world. Vol. 26. Estuaries of the world</span> </epp:phrase> 5) Add (and remove) the appropriate entries in you workflows (~/archives/myarchive/cfg/workflows/eprint/default.xml) in the "core" section: <!-- <component><field ref="title" required="yes" input_lookup_url="{$config{rel_cgipath}}/users/lookup/title_duplicates" input_lookup_params="id={eprintid}&dataset=eprint&field=title" /></component> --> <component><field ref="ml_title" required="yes"/></component> 6) Test and reload your archive for your changes to take effect: $ ./bin/epadmin test $ ./bin/epadmin reload myarchive Thanks everyone for the help, and especially Tim and Adam for making it possible!! :):) PS. Hope I haven't forgotten anything...:) On 26/06/2015 05:27 μμ, George Mamalakis wrote:
-- George Mamalakis IT and Security Officer, Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki), PhD (Aristotle Univ. of Thessaloniki), MSc (Imperial College of London) School of Electrical and Computer Engineering Aristotle University of Thessaloniki phone number : +30 (2310) 994379 |
- Follow-Ups:
- [EP-tech] Re: [Solved] Re: [spam?] Re: How to set a field to be multilang
- From: "Field A.N." <af05v@ecs.soton.ac.uk>
- [EP-tech] Re: [Solved] Re: [spam?] Re: How to set a field to be multilang
- References:
- [EP-tech] Re: How to set a field to be multilang
- From: Timothy Miles-Board <timothy.miles-board@ulcc.ac.uk>
- [EP-tech] Re: How to set a field to be multilang
- From: George Mamalakis <mamalos@eng.auth.gr>
- [EP-tech] Re: [spam?] Re: How to set a field to be multilang
- From: Alen Vodopijevec <alen@irb.hr>
- [EP-tech] Re: [spam?] Re: How to set a field to be multilang
- From: George Mamalakis <mamalos@eng.auth.gr>
- [EP-tech] Re: [spam?] Re: How to set a field to be multilang
- From: Timothy Miles-Board <timothy.miles-board@ulcc.ac.uk>
- [EP-tech] Re: [spam?] Re: How to set a field to be multilang
- From: George Mamalakis <mamalos@eng.auth.gr>
- [EP-tech] Re: How to set a field to be multilang
- Prev by Date: [EP-tech] Re: Shelves documentation (in response to Re: Collections package)
- Next by Date: [EP-tech] Re: Antwort: Re: Problem with the style sheet zzz_local.css
- Previous by thread: [EP-tech] Re: [spam?] Re: How to set a field to be multilang
- Next by thread: [EP-tech] Re: [Solved] Re: [spam?] Re: How to set a field to be multilang
- Index(es):