Difference between revisions of "Document fields automatic.pl"
(Added actually file name in bold.) |
|||
(One intermediate revision by one other user not shown) | |||
Line 2: | Line 2: | ||
{{cfgd}} | {{cfgd}} | ||
− | + | '''document_fields_automatic.pl''' contains the '''set_document_fields_automatic''' function. You use this function to perform a set of actions which you want to happen automatically before the [[API:EPrints/DataObj/Document|Document]] as part of the [[API:EPrints/DataObj/Document|Document]] commit() step, in which the document is written to the database. | |
* $doc is the [[API:EPrints/DataObj/Document|Document]] object | * $doc is the [[API:EPrints/DataObj/Document|Document]] object | ||
Line 12: | Line 12: | ||
my( $doc ) = @_; | my( $doc ) = @_; | ||
if($doc->value("description") eq ""){ | if($doc->value("description") eq ""){ | ||
− | $doc->value("description", "the default description"); | + | $doc->value("description", "the default description"); #if the documents description is empty set it to a holding value |
} | } | ||
}; | }; | ||
</pre> | </pre> |
Latest revision as of 12:14, 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
document_fields_automatic.pl contains the set_document_fields_automatic function. You use this function to perform a set of actions which you want to happen automatically before the Document as part of the Document commit() step, in which the document is written to the database.
- $doc is the Document object
Example
$c->{set_document_automatic_fields} = sub { my( $doc ) = @_; if($doc->value("description") eq ""){ $doc->value("description", "the default description"); #if the documents description is empty set it to a holding value } };