Difference between revisions of "Document fields default.pl"

From EPrints Documentation
Jump to: navigation, search
(Added infor about Document get_defaults method.)
(Added actually file name in bold.)
 
Line 2: Line 2:
 
{{cfgd}}
 
{{cfgd}}
  
The '''set_document_defaults''' function sets the default values for a Document. This usually happens when a Document is created but before it is given to the user to edit.
+
'''document_fields_default.pl''' contains the '''set_document_defaults''' function.  This function sets the default values for a Document. This usually happens when a Document is created but before it is given to the user to edit.
  
 
* '''<tt>$data</tt>''' is a hash reference of the metadata which will make up the document object. Each field name is a key in the hash.
 
* '''<tt>$data</tt>''' is a hash reference of the metadata which will make up the document object. Each field name is a key in the hash.

Latest revision as of 12:15, 27 January 2022

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


Back to cfg.d

document_fields_default.pl contains the set_document_defaults function. This function sets the default values for a Document. This usually happens when a Document is created but before it is given to the user to edit.

  • $data is a hash reference of the metadata which will make up the document object. Each field name is a key in the hash.
  • $session is a Repository object (in 3.2 or later).
  • $eprint is the EPrint object to which the document belongs.

Example

In this example, the default for language is set to the ID string of for the Repository object's language, which comes from the $c->{defaultlanguage} configuration setting in languages.pl and the default for security is set to public.

$c->{set_document_defaults} = sub
{
        my( $data, $session, $eprint ) = @_;

        $data->{language} = $session->get_langid();
        $data->{security} = "public";
};

N.B. There are also a number of defaults set by the EPrints::DataObj::Document::get_defaults method:

  1. pos is set to the next document position or to a bespoke position specified by $c->{ulimate_doc_pos} if it is defined.
  2. placement is set to the same value as pos as set above.