[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] epc and citation templates



Hmmm,
It's trivial to do using Lizz's example - or look at the default code for rendering multiple versions - calculate in perl, check for a $flags{something} in the epc.

There is a possibly useful method in EPrints::Script::Compiled (which seems to have escaped the clutches of documentation):
filter_compound_list

I've never used it, no one's ever written about it (as far as I can see, other than a mention in release notes).
*If* it works, you probably want something like this:
  <epc:if test="$item.filter_compound_list( 'locationelectronic', 'type', 'url' ).length = 0">
     <!-- print your message -->
  </epc:if>

Also, if it does work, shall we add some documentation about it somewhere?

Cheers,
John

From: eprints-tech-bounces at ecs.soton.ac.uk [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Matthew Brady
Sent: 30 June 2016 07:24
To: eprints-tech at ecs.soton.ac.uk
Subject: Re: [EP-tech] epc and citation templates

Hi again :)

More summary page citation rendering goodness...     Is there a way to display a message if something doesn't occur, using the epc script constructs...

e.g. in this code snippet...

<epc:foreach expr="locationelectronic" iterator="le">
       <epc:if test="$le{type} = 'url'">
              <li><a target="_top" href="//{$le{textual}}"><epc:print expr="$le{textual}" /></a></li><br/>
       </epc:if>
</epc:foreach>

If we have urls stored, then render them out... but if after looping through all the records, none of them were urls, then I want to display a message with some generic contact details...

Cheers

Matt



From: eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Matthew Brady
Sent: Wednesday, 29 June 2016 1:36 PM
To: eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>
Subject: Re: [EP-tech] epc and citation templates

Thanks for the feedback...

I tried to re-wrangle the EPrints::Script::Compiled with a new method, but it complained about undefined values, and it just didn't want to play nicely...

The data I was using was originally a field inside a compound,  I have updated the field definitions so its now a multiplele itemref field, not inside a compound type.
And now it is working...

I will work on Lizz's ideas as well, to get something that's going to suit this project, and let you know how it all works out when its done.

Thanks

Matt

From: eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of John Salter
Sent: Tuesday, 28 June 2016 9:22 PM
To: eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>
Subject: Re: [EP-tech] epc and citation templates

Hi Matt,
How do you get your list of related EPrintIDs?
Are they stored in a field, or calculated dynamically?

Lizz's suggestion is good.
If you *really* want to constrain yourself to use logic in the citation files, you will need to inject some extra methods into the EPrints::Script::Compiled module *unless* your EPrintIDs are stored in an 'Itemref' field.
If they're in an Itemref field, you can use the 'as_item' method.

If they're not, you can add something like (pseudo code!)
package EPrints::Script::Compiled
sub run_datasetid_and_id_to_dataobj
{
   my( $self, $state, $datasetid, $id) = @_;

  # turn $datasetid and $id into a dataobj

  # return [ $dataobj ];
}

And then use <epc:print expr="datasetid_and_id_to_dataobj( 'eprint', $eprintid ).citation('default')" />

An example of this technique at the end of this file: http://bazaar.eprints.org/207/1/epm/containers/cfg/cfg.d/z_containers.pl

Cheers,
John


From: eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Lizz Jennings
Sent: 28 June 2016 10:18
To: eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>
Subject: Re: [EP-tech] epc and citation templates

You can write a render method in eprint_render.pl (or wherever you have that configuration as it can be overridden).

I've used this as I have created a parent-child functionality, but you could obviously adapt this to what you were wanting to include.

https://gist.github.com/icklecows/da6b254563bed40f8bb2047756e91043

(and sorry for all the embedded styles in there, it's a temporary measure...)

You write the code to a fragment, and can then include the fragment in the summary_page.xml file.

Lizz

--
Lizz Jennings BA MSc ACLIP MCLIP (Revalidated 2015)
Technical Data Officer
The Library 4.10, University of Bath, Bath, BA2 7AY UK
Ext. 3570 (External 01225 383570)
E.Jennings at bath.ac.uk<mailto:E.Jennings at bath.ac.uk>
Research Data Management: http://www.bath.ac.uk/research/data




_____________________________________________________________

This email (including any attached files) is confidential and is for the intended recipient(s) only. If you received this email by mistake, please, as a courtesy, tell the sender, then delete this email.



The views and opinions are the originator's and do not necessarily reflect those of the University of Southern Queensland. Although all reasonable precautions were taken to ensure that this email contained no viruses at the time it was sent we accept no liability for any losses arising from its receipt.



The University of Southern Queensland is a registered provider of education with the Australian Government.

(CRICOS Institution Code QLD 00244B / NSW 02225M, TEQSA PRV12081 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160630/82c13c14/attachment-0001.html