Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Using the new API
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Reading EPrintID from input field== This is an extension of the previous exercise, it does not work without it. To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the call to action_process_input! Firstly lets make a form and append it to the output ($frag): my $form = $repository->render_form("POST"); .... $frag->appendChild( $form ); Next lets add an input field to hold the value the user types in and append this to the form (between the lines above): my $input_field = $repository->make_element( "input", name=> "input_field", type=> "text" ); $form->appendChild($input_field); Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. my $submit_button = $screen->render_action_button( { action => "process_input", screen => $screen, screen_id => $screen_id, } ); $form->appendChild($submit_button); NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines: my $screen_id = "Screen::".$self->{processor}->{screenid}; my $screen = $repository->plugin( $screen_id, processor => $self->{processor} ); Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id. To do this, find the previously added $self->action_process_input() line and change this to the following: my $input_value = $repository->param( "input_field" ); if ((!defined $eprint) and (defined $input_value)) { $self->action_process_input(); } Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL. Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method: $self->{actions} = [qw/ process_input /]; Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required! sub allow_process_input { my ( $self ) = @_; return 1; }
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)