EPrints Technical Mailing List Archive

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

Message: #07207


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

Re: [EP-tech] References not visible by default in the public view of item


Hi John,

Thank you very much for your reply.

 

I did as you have advised, I have added referencetext to eprint_render.pl and References appeared on the item page.

Next, I decided to add the function you gave to eprint_fields.pl

Everything worked well (newline appeared between references), but somehow the script replicates the whole reference list very many times.

I suppose this corresponds to the number of references I have in the list. Please see: https://eprints.ttu.ee/6/

So, something went wrong, although I double-checked all spaces and commas in the script after copying it. May-be a bracket is missing?

Do you have any idea?

Many thanks in advance.

Best,

Tarmo

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of John Salter
Sent: Tuesday, March 06, 2018 10:02 AM
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] References not visible by default in the public view of item

 

Hi Tarmo,

Welcome to EPrints!

 

For your first question:

In the Admin->Config Tools - View Configuration, find the file:

cfg/cfg.d/eprint_render.pl

 

At the top of this file is a section:

$c->{summary_page_metadata} = [qw/

                commentary

                note

                keywords

                subjects

                divisions

                sword_depositor

                userid

                datestamp

                lastmod

/];

 

If you add 'referencetext' in this list, it will appear on the item page.

The order of the items in the list is the order they will appear on the item page - if you want to move things around.

 

Also, the item page is cached - so a change to this file won't make a difference straight away.

You can make the item pages get regenerated from:

Admin->System Tools -> Regenerate abstracts.

 

For the second question, you can add a specific rendering method to the referencetext field.

There are a number of different ways to do this. Here is a possible solution:

In cfg.cfg.d/eprint_fields.pl, find the configuration for 'referencetext':

 

{

                name => 'referencetext',

                type => 'longtext',

                input_rows => 15,

},

 

To this, add a 'render_value' option. This can be a method from another module e.g.

render_value => 'EPrints::Extras::render_highlighted_field'

or, in this example a function.

I've saved the code below as a gist - in case the email formatting breaks it: https://gist.github.com/jesusbagpuss/a92036db2cd21223cf8db0d34fd7790b

 

{

                name => 'referencetext',

                type => 'longtext',

                input_rows => 15,

                render_value => sub {

                                my( $session , $field , $value ) = @_;  # see: https://wiki.eprints.org/w/Category:EPrints_Metadata_Fields#Rendering_Properties

 

                                my $frag = $session->make_doc_fragment;

 

                                # split value on a double-new line (possibly with other whitespace in between

                                foreach my $para ( split /\n[\r\s]*\n/, $value )

                                {

                                                my $p = $session->make_element( "p", class=>"referencetext" );

 

                                                # split text on new lines - rendering each one as a line-break

                                                foreach my $subpara ( split /\n[\r\s\n]*/, $value )

                                                {

                                                                $p->appendChild( $session->make_text( $subpara ) );

                                                                $p->appendChild( $session->make_element( "br" ) );

                                                }

 

                                                $frag->appendChild( $p );

                                }

                                return $frag;

                }

},

 

Are you experienced programming in Perl? If not, be careful! :o)

Doing things via the web interface should help you not break things (it checks files before installing them).

If you are - then editing some of these files might be easier on the command-line - there are other things that might be useful to know.

 

Let us know how you get on!

 

Cheers,

John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Tarmo Tuisk
Sent: 05 March 2018 12:04
To:
eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] References not visible by default in the public view of item

 

Hello,

I have recently installed EPrints v3.3.15

Generally everything works fine.

I have two questions.

1.       As Admin I have added article’s references to the section called References. These are visible in the Admin view,

but when an anonymous visitor accesses the page, and selects the publication, only the title, author(s) name and abstract and publishing date are displayed.

Where I can turn on also the option that References are displayed? I searched via Admin->Config.Tools->View Configuration, but could not find the right script to modify.

The problem applies to all entries, not a specific one. I need a solution for all the site.

 

I tried to copy article’s references to Additional Information field. Then it worked. Additional Information’s content (if existing) was displayed in the public view (i.e. for anonymous visitor).

2.       But the problem is with Additional Information field that all references are merged into one paragraph. <Enters> and double <enters>, also html <br></br> and <p></p> are ignored and displayed as syntax.

Is there any specific syntax I could use specially in these fields/windows (to force newline each reference) when entering bibliographic data? Or is there any workaround?

 

Please see example (problematic) repository entry at:

https://eprints.ttu.ee/6/

 

Many thanks in advance.

Best regards,

 

Tarmo Tuisk

Tallinn University of Technology