I've figured out my problem: in order to get the dates to display in the templates as stored, I removed selective calls to strtotime() in the MODS plugin file (i.e., where they were being processed for export to the templates), and removed 'date_format:$dateFormatShort' from the templates.
As a general approach to handling the formatting of metadata elements that would allow for overriding functions that currently exist in the schema *Plugin.inc.php files, could we consider using an external file containing 'preprocessor' functions similar to the ones used in other plugins? These functions, and the tokens in the templates, would use XPath-like expressions to identify specific element names (XPath since in MODS records, for example, you may want to format an element based on its context, e.g., abstract vs. relatedItem/abstract). These overrides should be applicable to a particular archive as well. The function signature of the preprocessor plugin function preprocessEntry() might serve as a model:
- Code: Select all
function preprocessEntry(&$archive, &$record, &$field, &$value, &$attributes) {
/*
* Add your regular expressions, and any conditional logic, here. You can use
* methods like $archive->getArchiveId() and $field->getName() in your code.
* This example removes periods from the ends of subject elements:
*
* if ($field->getName() == 'subject') {
* $value = preg_replace('/\.$/', '', $value);
* }
*/
return false;
}
Instead of expressions like '$field->getName() == 'subject'', we'd use the XPath-like expressions like '$field->getName() == "relatedItem/abstract"'. What I'm thinking is that these overrides could go into a file of a speicifc name, like template_preprocessor.inc.php, and if it's present, it is included and all entries run though it. On the template side, XPath expressions could be used as tokens so the template knows which overridden variables to use.