EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #09831


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

Re: [EP-tech] Conditional EPrints Field Names based on Eprint Type


CAUTION: This e-mail originated outside the University of Southampton.
Hi John,

Thank you for this. It is exactly what I needed and exactly what I was looking to do.

I am having some difficulty with it. It can change the phrase in the edit screen for the fields. E.g. you click on the field and it takes you to the screen where you change field values and save, move to the next stage etc. It will not do it on the screen where it lists all the fields and you can click the tabs across the top of the screen (preview, details, actions, history etc), with this url: http://repo-test.liv.ac.uk/cgi/users/home?screen=EPrint::View&eprintid=3000001#t. The result is I have a field showing asAbstract, then when a user clicks to edit it shows as Description.

Doing some Data dumping, I can see in MetaField.pm that $dataobj in sub render_name is empty/undef. I think this is called from plugins/EPrints/Plugin/Screen/EPrint/Details.pm. I'm not sure if this is intended behaviour, or a problem isolated to my EPrints. I do have two customised plugins:

cfg/plugins/EPrints/Plugin/Screen/EPrint/LocalDetails.pm
cfg/plugins/EPrints/Plugin/Screen/EPrint/LocalView.pm

I have disabled both of these, restarted Apache etc. I've also ensured my versions of these files match those on the 3.4.4 github.

I'm not too sure what to do with it. I'll continue playing around with it today. I'm thinking "all I need to do is pass the item type over to render_name" but I obviously don't know where this sub is called elsewhere and what the consequences of that might be.

Thanks,
James

On Fri, Aug 23, 2024 at 9:27 AM John Salter <J.Salter@leeds.ac.uk> wrote:
CAUTION: This e-mail originated outside the University of Southampton.
CAUTION: This e-mail originated outside the University of Southampton.

There might be some 'magic' that EPrints can already do for you here…

 

https://github.com/eprints/eprints3.4/blob/master/perl_lib/EPrints/MetaField.pm#L425-L430

 

I think this allows you to define a phrases such as:
<epp:phrase id="eprint_fieldname_abstract">Abstract</epp:phrase>

<epp:phrase id="eprint_fieldname_abstract.report">Executive Summary</epp:phrase>

 

The first would be used for more items, the second for 'report' eprints.

 

I've never used it – but had made a mental note many years ago that it might be useful one day!

 

Cheers,

John

 

From: eprints-tech-request@ecs.soton.ac.uk <eprints-tech-request@ecs.soton.ac.uk> On Behalf Of James Kerwin
Sent: Friday, August 23, 2024 9:11 AM
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Conditional EPrints Field Names based on Eprint Type

 

CAUTION: External Message. Use caution opening links and attachments.

CAUTION: This e-mail originated outside the University of Southampton.

CAUTION: This e-mail originated outside the University of Southampton.

Okay, so I'm revising what I thought in the first email.

 

I think a potential starting point is in: /opt/eprints3/perl_lib/EPrints/Plugin/Screen/EPrint/Details.pm around this area:

oreach my $field ( @fields )
{
next unless( $field->get_property( "show_in_html" ) );

my $name = $field->get_name();

my $stage = $self->_find_stage( $eprint, $name );
$stage = "" if !defined $stage;

my $rows = $stages{$stage}->{rows};
my $unspec = $stages{$stage}->{unspec};
$stages{$stage}->{count}++;

my $r_name = $self->_render_name_maybe_with_link( $eprint, $field );

if( $eprint->is_set( $name ) )

{

if( !$field->isa( "EPrints::MetaField::Subobject" ) )

{

push @$rows, $session->render_row(

$r_name,

$eprint->render_value( $field->get_name(), 1 ) );

}

}

 

Thanks,

James

 

On Fri, Aug 23, 2024 at 7:37 AM James Kerwin <jkerwin2101@gmail.com> wrote:

Hi All,

 

We're sprucing up the repository, which is awful news for me.

 

I need to alter how certain field names are rendered, depending on the EPrint type.

 

For example, if an item is an Article type I want the abstract to continue to be rendered as "Abstract". For report I want the Abstract to be rendered as "Executive Summary". That sort of thing. I can do this easily enough using epc:if in the summary_page.xml citation, but I want the field names to be consistent in the Details screen where my team log in.

 

Ideally I would do something in cfg.d, but I think it's going to be more involved than that. I'm aware I could simply conditionally map this in the crosswalks, but I'm trying to limit the number of new fields I create because we already have a lot.

 

Is there a way I should go about this? Looking at Details.pm I can see a "render_name" sub being called. I THINK the version of this I need to alter might be in MetaField.pm, but I'm really not sure.

Does anyone know if this would be possible and where I should start with it? I'm not looking for a fully flushed out solution, just some direction.

Thanks,

James

*** Options: https://wiki.eprints.org/w/Eprints-tech_Mailing_List
*** Archive: https://www.eprints.org/tech.php/
*** EPrints community wiki: https://wiki.eprints.org/