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!
==Searching== First things first we need a place to store a list of eprints rather than just one. Let's declare (or change the existing) global variable eprints: our $eprints = undef; Next lets change the action_process_input method to perform a search, to do this find the line which reads the "input_field" parameter and change this: my $input_value = $repository->param( "input_field" ); As this no longer represents an EPrint ID we'll rename the parameter. You can delete all the lines after this in the action_process_input method as we are going to replace them all. Next lets get the eprint dataset so we can search it: my $eprint_dataset = $repository->dataset( "eprint" ); Now we are going to search on TITLE so lets define the filter for the search. Here we are doing a fuzzy search (the match => EX parameter is not used). my @filters = ( { meta_fields => [qw( title )], value => $input_value }, ); Now lets do the search and assign the output to our list of eprints: $eprints = $eprint_dataset->search( filters => \@filters, custom_order=>"-datestamp", limit => 10, ); Notice that we are setting an order (based upon age) for the eprints to be listed in. Also we are limiting the number returned to 10. Finally lets do some error handling if the list is empty and nothing was found. This is just a little more detailed than before. if (!defined $eprints or $eprints->count < 1) { $self->{processor}->add_message( "error", $self->{repository}->make_text("No EPrints found to match search: $input_value") ); }
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)