Difference between revisions of "Boxes on Abstract Pages"

From EPrints Documentation
Jump to: navigation, search
(Extension Exercise)
m (Fixed a couple of typos)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category:EPrints_Bazaar]]
 
This tutorial looks at ways to add items to eprint abstract pages without the need to manipulate any XML code.  
 
This tutorial looks at ways to add items to eprint abstract pages without the need to manipulate any XML code.  
  
Line 9: Line 10:
 
These are very simple and live under the Screen plug-ins Box directory:
 
These are very simple and live under the Screen plug-ins Box directory:
  
* cfg/plugins/EPrints/Plugin/Screen/EPrint/Box/package_name.pm
+
* lib/plugins/EPrints/Plugin/Screen/EPrint/Box/package_name.pm
  
 
All they require is a render method as shown in the basic shell below:
 
All they require is a render method as shown in the basic shell below:
Line 42: Line 43:
 
   $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_left} = undef;
 
   $c->{plugins}->{"Screen::EPrint::Box::package_name"}->{appears}->{summary_left} = undef;
  
So this box will appear bellow the summary_page citation with a priority of 800 (anything less will appear below and anything more above).
+
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=
 
=Installing as a package=
  
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.  
+
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=
 
=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!
 
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!

Latest revision as of 15:32, 29 January 2015

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();