Doc rewrite.pl
Revision as of 10:20, 4 February 2022 by Drn@ecs.soton.ac.uk (talk | contribs) (Added page about config file)
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
doc_rewrite.pl contains an EP_TRIGGER_DOC_URL_REWRITE trigger to take the request document URL and ensure the right version is returned based on the relationship (to the original document) supplied in the call. E.g. Returning the thumbnail preview of the document.
Example
$c->add_trigger( EP_TRIGGER_DOC_URL_REWRITE, sub { my( %args ) = @_; my( $request, $doc, $relations, $filename ) = @args{qw( request document relations filename )}; foreach my $r (@$relations) { $r =~ s/^has(.+)$/is$1Of/; $doc = $doc->search_related( $r )->item( 0 ); if( !defined $doc ) { $request->status( 404 ); return EP_TRIGGER_DONE; } $filename = $doc->get_main; } $request->pnotes( dataobj => $doc ); $request->pnotes( filename => $filename ); }, priority => 100 );