Boxes on Abstract Pages

From EPrints Documentation
Revision as of 15:32, 29 January 2015 by Drn@ecs.soton.ac.uk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This tutorial looks at ways to add items to eprint abstract pages without the need to manipulate any XML code.

This can be done by adding a box to either the top,bottom,left or right of the abstract page.

These can be useful but don't always turn out in the correct place, hence manipulating XML can be more preferable in the long run.

An EPrints Box

These are very simple and live under the Screen plug-ins Box directory:

  • lib/plugins/EPrints/Plugin/Screen/EPrint/Box/package_name.pm

All they require is a render method as shown in the basic shell below:

 package EPrints::Plugin::Screen::EPrint::Box::package_name;
 
 @ISA = ( 'EPrints::Plugin::Screen::EPrint::Box' );
 
 use strict;
 
 sub render
 {
       my( $self ) = @_;
 
       my $repository = $self->{repository};
       my $eprint = $self->{processor}->{eprint};
 
       my $frag = $repository->make_doc_fragment;
       
       $frag->appendChild($repository->make_text("HELLO"));
 
       return $frag;
 }

Configuring your box

For this you need a config file in cfg/cfg.d/package_name.pl which contains the following:

 $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_top} = undef;
 $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_right} = undef;
 $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_bottom} = 800;
 $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_left} = undef;

So this box will appear below the summary_page citation with a priority of 800 (anything less will appear below and anything more above).

Installing as a package

To see your box you will need to invalidate the abstract pages which can be done via the "Regenerate Abstracts" button under the "System Tools" tab of the admin interface.

If you specify you config file properly in the spec file you should be able to click the "Configure Add-on" button to change these values.

Extension Exercise

It is recommended that this exercise is done after XML manipulation of the Abstract page using a Bazaar Module

Make a screen plug-in which has a postinst and prerm which invalidate the abstract pages. The render method of this screen should still re-direct the user to the config file however!

For the invalidate abstract code see XML manipulation of the Abstract page using a Bazaar Module

Clue to the redirecting:

 my $config_file = "cfg.d/package_name.pl";
 my $screen_id = "Admin::Config::View::Perl";
 my $redirect_url = $session->current_url() . "?screen=" . $screen_id . "&configfile=" . $config_file;
 $session->redirect( $redirect_url );
 exit();