Difference between revisions of "Adding new views"

From EPrints Documentation
Jump to: navigation, search
(Linking in your view)
Line 3: Line 3:
 
__TOC__
 
__TOC__
  
===Adding a new view===
+
===View fast track===
  
 
This section describes how to quickly add a new view to your repository.
 
This section describes how to quickly add a new view to your repository.
Line 28: Line 28:
 
* Those familiar with Perl will recognise the browse_views setting as a reference to an array of hash references.
 
* Those familiar with Perl will recognise the browse_views setting as a reference to an array of hash references.
  
'''Example 1 Browse by organisational structure'''
+
====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:
 
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:
Line 49: Line 49:
 
  ];
 
  ];
  
'''Example 2 Browse by type'''
+
====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:
 
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:
Line 60: Line 60:
 
  },
 
  },
  
After adding a new view definition, save the file generate the new view pages:
+
====Testing new views====
 +
 
 +
After adding a new view definition, save the file and generate the new view pages:
  
 
  bin/generate_views ARCHIVEID --verbose
 
  bin/generate_views ARCHIVEID --verbose
  
 
(this will also re-generate any existing views defined in the views configuration file).
 
(this will also re-generate any existing views defined in the views configuration file).
 
====Testing new views====
 
  
 
Open the view page in a Web browser:
 
Open the view page in a Web browser:
Line 76: Line 76:
 
[[Image:View_page.png]]
 
[[Image:View_page.png]]
  
'''Naming your view
+
====Naming new views====
  
 
Your new view may appear on the views page with an ''undefined phrase'' warning:
 
Your new view may appear on the views page with an ''undefined phrase'' warning:
Line 100: Line 100:
 
====Linking in your view====
 
====Linking in your view====
  
'''Example 1 Add your view to the navigation bar
+
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.
 
 
Open the site template:
 
 
 
/opt/eprints3/archives/devel/cfg/lang/en/templates/default.xml
 
 
 
Find the navigation bar:
 
 
 
<pre>
 
<ul class="ep_tm_menu"> ... <li><a href="{$config{base_url}}/view/subjects">Browse by Subject</a></li></ul>
 
</pre>
 
 
 
Add a link to your new view:
 
 
 
<pre>
 
<ul class="ep_tm_menu"> ... <li><a href="{$config{base_url}}/view/subjects">Browse by Subject</a></li><li><a href="{$config{base_url}}/view/divisions">Browse by Division</a></li></ul>
 
</pre>
 
 
 
Reload the template:
 
 
 
bin/epadmin reload ARCHIVEID
 
 
 
'''Example 2 Add link to views page
 
 
 
Rather than link directly to each view, you may prefer to add a Browse option to the navigation bar which
 
  
 
[[Image:Browse_by_navbar.png]]
 
[[Image:Browse_by_navbar.png]]

Revision as of 17:56, 1 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.

View fast track

This section describes how to quickly add a new view to your repository.

Open the views configuration file in a text editor:

/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl

Find the browse_views configuration setting:

$c->{browse_views} = [
       {
               id => "year",
               ...
       },
       {
               id => "subjects",
               ...
       },
];

Each view is 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).

  • Those familiar with Perl will recognise the browse_views setting as a reference to an array of hash references.

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,
},

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.

View page.png

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>

Reload the phrase files:

bin/epadmin reload ARCHIVEID

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.

Browse by navbar.png

Advanced views

Multiple field views

Division->Author

Journal->ISSN

Generating CVs etc

Linking items back to views

Views as collections

discover related content

There are two ways in which visitors to your repository may discover relevant content - searching

Visitors to your repository can take advantage