EPrints Technical Mailing List Archive
Message: #06702
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
Re: [EP-tech] Tweaking the "creators" section on the workflow
- To: eprints-tech@ecs.soton.ac.uk
- Subject: Re: [EP-tech] Tweaking the "creators" section on the workflow
- From: Christopher Gutteridge <cjg@ecs.soton.ac.uk>
- Date: Wed, 12 Jul 2017 14:13:15 +0100
To flesh that out a bit more. There's a bit of code I wrote that
lets you get a single property from a "compound" field. This lets
you loop over a field like creator and set how it renders each
item in the loop. However, this only changes how it renders on the
summary (or citation). The solution with DOM hacking in perl is
required to change the way it renders throughout the system. example for the citations/eprints/summary_page.xml file; <epc:foreach expr="$item{dates}" iterator="date"> <div class='uos-eprints-dv'><span class='uos-eprints-dv-label'><epc:print expr="$date.subproperty('date_type')" /> date:</span> <epc:print expr="$date.subproperty('date')" /></div> </epc:foreach> (you'd have to tweak this to loop over creators and render the subproperties how you like) Add this Code to eprint_render.pl: sub EPrints::Script::Compiled::run_subproperty { my( $self, $state, $objvar, $value ) = @_; if( !defined $objvar->[0] ) { $self->runtime_error( "can't get a property {".$value->[0]."} from undefined value" ); } my $ref = ref($objvar->[1]); if( $ref !~ m/::/ || ! $objvar->[1]->isa( "EPrints::MetaField::Compound" ) ) { $self->runtime_error( "can't get a subproperty from anything except a compound field value, when trying to get ".$value->[0]." from a $ref" ); } my $field = $objvar->[1]; if( $field->get_property( "multiple" ) ) { $self->runtime_error( "can't get a subproperty from a multiple field." ); } my $fc = $field->get_property( "fields_cache" ); my $sub_field; my @ok = (); foreach my $a_sub_field ( @{$fc} ) { push @ok, $a_sub_field->{sub_name}; if( $a_sub_field->{sub_name} eq $value->[0] ) { $sub_field = $a_sub_field; } } if( !defined $sub_field ) { $self->runtime_error( "unknown sub-field of a compound: ".$value->[0].". OK values: ".join( ", ", @ok )."." ); } $sub_field->set_property( "multiple", 0 ); return [ $objvar->[0]->{ $value->[0] }, $sub_field ]; }; On 12/07/2017 12:22, Christopher
Gutteridge wrote:
-- Christopher Gutteridge -- http://users.ecs.soton.ac.uk/cjg University of Southampton Open Data Service: http://data.southampton.ac.uk/ You should read our Web & Data Innovation blog: http://blogs.ecs.soton.ac.uk/webteam/ |
- References:
- Re: [EP-tech] Tweaking the "creators" section on the workflow
- From: Christopher Gutteridge <cjg@ecs.soton.ac.uk>
- Re: [EP-tech] Tweaking the "creators" section on the workflow
- Prev by Date: Re: [EP-tech] Tweaking the "creators" section on the workflow
- Next by Date: [EP-tech] HTTPS part not working.
- Previous by thread: Re: [EP-tech] Tweaking the "creators" section on the workflow
- Next by thread: Re: [EP-tech] FW: Issues uploading files
- Index(es):