EPrints Technical Mailing List Archive

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

Message: #04328


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

[EP-tech] Re: Rendering a metafield - use different format in Listing and Abstract page


You can test for field A, and render field B in epxml, but that does complicate things slightly.  The final alternative is to (ugh) use an automatic field and copy the value in A to B, and then you can do the tests, but you'll be storing the data twice.

--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services
+44 (0)23 8059 8814





On 18 Jun 2015, at 12:33, John Salter wrote:

> Hi Adam,
> Thanks for the pointers.
>  
> I think I can achieve what I need through this – but I don’t think I can order a review column based on a virtual field – so I’ll have to make the default rendering be the list-style, and use the virtual field for the abstract page – but that might also fall foul of your comment about epxml :o\
>  
> Cheers,
> John
>  
>  
>  
> From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Adam Field
> Sent: 17 June 2015 19:42
> To: eprints-tech@ecs.soton.ac.uk
> Subject: [EP-tech] Re: Rendering a metafield - use different format in Listing and Abstract page
>  
> I've solved this problem by using a virtual field with a custom renderer.  The virtual field's render method reads the value from the actual field you're interested in and renders it differently.  The problem with virtual fields is that I think they're hard to test for in epxml (and possibly also with is_set).
>  
> You can see an example from the tweepository package here:
>  
>             https://github.com/gobfrey/tweepository/blob/master/cfg/cfg.d/z_tweepository_libs.pl#L314 (field definition)
>             https://github.com/gobfrey/tweepository/blob/master/cfg/cfg.d/z_tweepository_libs.pl#L1710 (render method)
>  
> --
> Adam Field
> Business Relationship Manager and Community Lead
> EPrints Services
>  
> On 17 Jun 2015, at 17:47, John Salter <J.Salter@leeds.ac.uk> wrote:
>  
> Hi,
> I'd like to be able to apply a different rendering to a field if it's being displayed in a listing (e.g. the Review screen) to how it gets rendered 'normally'.
> 
> In this specific case, a compound field is normally rendered as a table:
> +----------+----------+
> | Sub A    | Sub B    |
> +----------+----------+
> | Val 1A   | Val 1B   |
> | Val 2A   | Val 2B   |
> | Val 3A   | Val 3B   |
> +----------+----------+
> 
> This rendering is OK on an abstract page, but when using the compound field as a review column, I want to render is as a list:
> * Val 1B (Val 1A)
> * Val 2B (Val 2A)
> * Val 3B (Val 3A)
> 
> Is there a way (in the render_value of a field) to determine if the field is being rendered as part of a listing?
> I've got access to the $session - so was thinking along the lines of (CAUTION: nonsense code!)
> if( $session->{screen}->isa( "EPrints::Screen::Listing" ) ){
>             #do list rendering
> } else {
>             #revert to normal table rendering
> }
> 
> but I can't quite get my head around going from session to screen. Any pointers welcome!
> 
> I may be missing something obvious too - e.g. if there's a citation style that I should use to do this!
> 
> Cheers,
> John
> 
> 
> 
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/
>  
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/