Difference between revisions of "Adding new views"
(→Views as collections) |
(→The views configuration file) |
||
Line 5: | Line 5: | ||
===The views configuration file=== | ===The views configuration file=== | ||
− | + | The set of views generated by your repository is defined in the views configuration file: | |
− | |||
− | |||
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl | /opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl | ||
− | + | Open this file and find the browse_views configuration setting: | |
$c->{browse_views} = [ | $c->{browse_views} = [ | ||
Line 24: | Line 22: | ||
]; | ]; | ||
− | + | The views are defined using a special (Perl) syntax: the view definition consists of a pair of curly braces (''note the comma after each closing brace'') enclosing a list of property/value pairs (note ''the comma'' after each line). | |
===Example views (single field)=== | ===Example views (single field)=== |
Revision as of 17:09, 6 February 2007
Browse views provide a way for visitors to your site to discover relevant content without a specific item in mind (for example, browsing all the content associated with a particular topic). Visitors arriving directly at the page for a specific item in the repository (for example, via a search engine) may also use the views to discover other related content. There are two default views in EPrints - By Year and By Subject. This guide describes how to add additional views to your repository.
Contents
The views configuration file
The set of views generated by your repository is defined in the views configuration file:
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl
Open this file and find the browse_views configuration setting:
$c->{browse_views} = [ { id => "year", ... }, { id => "subjects", ... }, ];
The views are defined using a special (Perl) syntax: the view definition consists of a pair of curly braces (note the comma after each closing brace) enclosing a list of property/value pairs (note the comma after each line).
Example views (single field)
Browse by organisational structure
By default, EPrints has a divisions metadata field which allows authors to associate their deposits with the divisions (units, faculties, schools, departments, institute, centre..) that were involved in producing their item (for example, the author's department, and the departments of his co-authors). To allow visitors to the repository to browse the content by division, add the following definition to the browse_views setting:
$c->{browse_views} = [ { id => "year", ... }, { id => "subjects", ... }, { id => "divisions", fields => "divisions", order => "-date/title", hideempty => 1, }, ];
Browse by type
Every deposit in EPrints has a type (article, book, thesis...). To allow visitors to browse your repository content by type, add the following definition to the browse_views setting:
{ id => "types", fields => "type", order => "-date/title", hideempty => 1, },
Browse by author
Example views (combined fields)
Browse by author and editor
Example views (multiple fields)
It is also possible to browse by more than one field.
Browse by journal title, then by volume
This example lets visitors browse the journals items in your repository have been published in, and then volumes within each journal.
{ id=>"journal_volume", fields=>"publication,volume", order=>"-date/title", hideempty => 1, },
Testing new views
After adding a new view definition, save the file and generate the new view pages:
bin/generate_views ARCHIVEID --verbose
(this will also re-generate any existing views defined in the views configuration file).
Open the view page in a Web browser:
http://your.repository.url/view/
The view page lists all the available views. You should see your new views on the list.
Naming new views
Your new view may appear on the views page with an undefined phrase warning:
["viewname_eprint_divisions" not defined]
(you may also notice a similar warning message when running generate_views).
Each view you create needs to be assigned a name, which EPrints will use to display the view.
Edit the language-specific phrases file for view names:
/opt/eprints3/archives/devel/cfg/lang/en/phrases/views.xml
Add an appropriate phrase which describes your new view, for example:
<epp:phrase id="viewname_eprint_divisions">Division</epp:phrase>
Regenerate the view pages:
bin/generate_views ARCHIVEID --verbose
Linking in your view
You now need to add a link to your repository pages which takes visitors directly to your new view, or to the views page from where they can access all available views.