EPrints 2.0 Documentation - How-To Guides |
Simple instructions are in the ArchiveConfig.pm section.
Example situation: On my main website www.foobars.ac.uk I have a page per research project, of which we have hundreds. Each project has a short unique id code, eg. ``manticore''. I have a field in my eprints archive (eprints.foobars.ac.uk) which is configured:
{ name=>"projectcodes", type=>"text", multiple=>1 }
I add the following browse view:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title" }
This will generate a page http://eprints.foobars.ac.uk/views/by_project/manticore.html with a list of all papers in that project, we can link to that URL!
If you want a subject to link the subject browse page of that value, add the browse_link property to the field (and regenerate the abstracts if you want).
If you remove the browse view you should remove the browse_link or it will be a broken link.
Values rendered inside citations which are used to link to the main record will not link into the browse view for obvious reasons.
If you change that to:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title", noindex=>1, nolink=>1, nohtml=>1, include=>1 }
This will generate a view which is NOT listed on the /view/ page and it will not skip making the .html file and make a .include file per value. This will only contain the ``count'' of items and the XHTML of their citations. This can be used as part of a page on the http://www.foobaars.ac.uk/ site; either by using php and capturing it on-the-fly using readfile
or scripting it with perl or NFS exporting the filesystem onto the main server (or just doing it all on one computer) and using server side includes to place it in a page.
I want to list the project papers in a strict format in a table with 4 columns: title, author(s), year and an icon which links to the document abstract page...
I add some more options to the browse view:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title", noindex=>1, nolink=>1, nohtml=>1, include=>1, nocount=>1, citation=>"project_table" }
Now I add a new citation to the citations config file:
<ep:citation type="project_table"><tr><td>&title;</td><td>&authors;</td> <td>&year;</td><td><ep:linkhere><img src="http://www.foobars.ac.uk/images/paperlink.png" alt="view" width="32" height="64" border="0" /></ep:linkhere></td></tr></ep:citation>
That should generate for the manticore project, in the ``.include'' file (I've cut the contents of the ``img'' tag for readability:
<tr><td>Making Stuff</td><td>Guy, A.</td><td>2001</td><td><a href="http://eprints.foobar.ac.uk/archive/00000923/"><img ... /></a> </td></tr> <tr><td>Eating Food</td><td>Herring, Walter and Chips, Bob</td><td> 2000</td><td><a href="http://eprints.foobar.ac.uk/archive/00000445/"> <img ... /></a></td></tr>
This is where the authors and editors field having an ID comes in handy.
Say we use local username to identify people in the ``Person ID'' fields, we can now set up a view:
{ id=>"by_person", allow_null=>0, fields=>"authors.id/editors.id", order=>"-year/title", noindex=>1, include=>1 }
This will generate both .html pages and .include pages. An member of your organisation can get
a list of their records either by linking to /views/by_person/alice.html
(where alice is their username) or by snarfing the URL /views/by_person/alice.include
into his own homepage.
This convers adding a new field to a new system, not a live system. It is possible to add a new field to a live system but invloves SQL hacking.
In this example we add a new ``set'' field called ``local'' which will have 3 options ``yes'',``no'' and ``partial'' - this will indicate if the item in question was produced in our organisation or not.
{ name => "local", type => "set", input_rows => 1, options => [ "yes", "no", "partial" ] }
input_rows being set to one will make it appear as a pull-down menu.
<field name="local" required="yes" />
File(s)
<ep:phrase ref="eprint_fieldname_local">Produced Locally</ep:phrase> <ep:phrase ref="eprint_fieldhelp_local">Please indicate if this item was produces in the foo organisation, or not. <ep:phrase ref="eprint_fieldopt_local_yes">produced locally</ep:phrase> <ep:phrase ref="eprint_fieldopt_local_no">not produced locally</ep:phrase> <ep:phrase ref="eprint_fieldopt_local_partial">only partially produced locally</ep:phrase>
In our example case we only want this to appear when citing technical reports, so we change that entry to:
<ep:citation type="eprint_techreport"><ep:linkhere><span class="citation">&authors; <ep:ifset name="year">(&year;) </ep:ifset>&title;. Technical Report<ep:ifset name="reportno"> &reportno;</ep:ifset><ep:ifset name="department">, &department; </ep:ifset><ep:ifset name="institution">, &institution;</ep:ifset>. &local;.</span></ep:linkhere></ep:citation>
All we've done is add &local;.
to the end. It's not inside <ep:ifset name="local">
as it is a required field and will (should) always be set.
In our example we only want to mention items if an item was not produced locally. We'll add it below the documents and above the abstract...
Single language example:
if( $eprint->get_value( "local" ) ne "yes" ) { # don't need to "my $p" as it's done earlier. $p = $session->make_element( "p" ); $p->appendChild( $session->make_text( "This item was " ) ); $p->appendChild( $eprint->render_value( "local" ) ); $p->appendChild( $session->make_text( "." ) );
# Append our new paragraph to the page. $page->appendChild( $p ); }
Multiple-language example:
If you want to make it handle more than language then we'll need to use the archive phrase file - we would add something like this to each languages file:
<ep:phrase ref="page:itemnotlocal"><p>This item was <pin ref="status" />.</p></ep:phrase>
And to the ArchiveRenderConfig.pm file:
if( $eprint->get_value( "local" ) ne "yes" ) { my $localmsg = $session->html_phrase( "page:itemnotlocal", status=>$eprint->render_value( "local" ) ); $page->appendChild( $localmsg ); }
You may prefer to use this method even if you are only using a single language.
If you add a field you will need to run erase_archive and create_tables before you will see a change. EPrints will fail to run if you change the fields and do rebuild the tables.
The quick answer is to say ``the opposite of adding one''.
file(s)
Add the eprint type to metadata-types.xml. Some fields should probably be ``required''.
Add the name of the type to the phrase file.
Add a citation for this type to the citations file.
Remove it from metadata-types.xml
You can remove it from the phrase file & citations but it won't hurt to leave it there.
Add it to metadata-types.xml. This does not need any fields.
Add the name of the document type to the phrase file.
Add a citation for this document to the citations file.
If you want this to be one of the must-have-one-of document types then add it's id to the list in ArchiveConfig.pm
If you want to do something ``clever'' on the abstract page then edit the ArchiveRenderConfig.pm file. If you don't then it will use the citiation you created to render it in the list, as with PDF, HTML etc.
EPrints 2.0 Documentation - How-To Guides |