EPrints Technical Mailing List Archive

Message: #01935


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] EPrints customization adding a dropdown menu with autocomplete


Hi,

I need to make some customizations to EPrints workflow pages, one of them and up to now the most difficult one for me is that in the "Details" stage in the workflow, where you put most of the item metadata like authors, etc.

Out-of-the-box EPrints comes with 3 fields to place the "Creators" of the item:

- Family Name
- Given Name / Initials
- Email

Right now although there is an auto-completation feature, many times information is entered in a wrong way, and hence it creates inconsistencies in our repository and we have to be fixing them manually.

I want to create a sort of dropdown menu that contains the names of our internal authors for publications, so when somebody have to place the name of one of our authors, it can be selected from the dropdown menu instead of having to write it (which is more error-prone).

This should look like this:

http://oi41.tinypic.com/30nhvly.jpg

The problem I'm having here, is that I would want that when somebody selects one author from the dropdown menu, rest of the fields ( Family Name, Given Name, and Email ) get populated automatically as it would if I use the auto-complete that comes out-of-the-box with EPrints.

I've ben been taking a look at the code and created a different script under the same directory where other cgi scripts are, but since I'm not an expert in Perl or SQL, I can't fully understand everything there.

Basically what I did was to copy the "name" script to a one called "internal_authors" and try to customize it a bit to take it as a base, here is the content of this file so far:

use EPrints;

use strict;

my $session = EPrints::Session->new();

# security?

my $content = "text/xml";
$session->send_http_header( content_type=>$content );
my $family = $session->param( "_name_family" );
my $given = $session->param( "_name_given" );
my $id = $session->param( "_id" );

my $database = $session->get_database;
my $dataset = $session->dataset( "eprint" );
my $name_field = $dataset->get_field( "creators_name" );
my $id_field = $dataset->get_field( "creators_id" );

# Here is the one that I've added for my new field
my $imdea_author_field = $dataset->get_field( "creators_imdea_author" );

my @fields = ( $name_field->get_sql_names, $id_field->get_sql_names);

But from here to to the EOF I don't know how to follow because I don't understand EPrints data structure nor the SQL statements and rest of the code..

In theory, with what I want it should be simpler than the out-of-the-box mechanism, in the sense that I would query the database to return me the rights values (associated with the email of each author) instead a list for the user to choose from when he types a letter and then multiple options appear in the text field.

Anyone could please give me any hint or help me anyhow?

Thanks in advance.

--

Joel Rosental R.
System Administrator

Tel: +34 91 481 69 87
Web: http://www.networks.imdea.org