About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:architecture:record_data_formatter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
development:architecture:record_data_formatter [2020/02/27 14:09] – [Specification Array] demiankatzdevelopment:architecture:record_data_formatter [2022/12/20 13:03] – [Basic Concept] demiankatz
Line 12: Line 12:
   * A [[development:plugins:record_drivers|record driver]] object.   * A [[development:plugins:record_drivers|record driver]] object.
  
-As output, getData() returns different formats depending on your VuFind version. In 4.x, it is an associative array of field name <nowiki>=></nowiki> another associative array containing HTML output ('value' key) and contextual information ('context' key) for the corresponding field. :!: Starting with 5.0, the return format changes to a non-associative array of arrays, with each sub-array containing a 'label' key for the field name.+As output, getData() returns different formats depending on your VuFind version. In 4.x, it is an associative array of field name <nowiki>=></nowiki> another associative array containing HTML output ('value' key) and contextual information ('context' key) for the corresponding field. 
 + 
 +:!: Starting with 5.0, the return format changes to a non-associative array of arrays, with each sub-array containing a 'label' key for the field name
 + 
 +:!: Starting with 9.0, the record driver parameter to getData is optional; you can instead pass it directly to the view helper when the helper is invoked -- e.g. <nowiki>$this->recordDataFormatter($driver)->getData($specs)</nowiki> instead of <nowiki>$this->recordDataFormatter()->getData($driver, $specs)</nowiki>.
  
 Field names are raw and should be translated/escaped when displayed in templates. Field names are raw and should be translated/escaped when displayed in templates.
Line 45: Line 49:
 ===== The Specification Builder ===== ===== The Specification Builder =====
  
-A [[https://github.com/vufind-org/vufind/blob/master/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter/SpecBuilder.php|SpecBuilder]] convenience class has been provided to help generate specification arrays. This handles such functionality as auto-generating useful 'pos' values, reordering/overriding fields, etc.+A [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatter/SpecBuilder.php|SpecBuilder]] convenience class has been provided to help generate specification arrays. This handles such functionality as auto-generating useful 'pos' values, reordering/overriding fields, etc.
  
 Useful public methods: Useful public methods:
Line 59: Line 63:
 ==== Option 1: Override the Factory ==== ==== Option 1: Override the Factory ====
  
-If you want to make global changes to a specification, the easiest solution is to extend [[https://github.com/vufind-org/vufind/blob/master/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php|\VuFind\View\Helper\Root\RecordDataFormatterFactory]] in your own [[development:architecture:customizing_vufind#modules|custom module]] and override getDefaultCoreSpecs() and/or getDefaultDescriptionSpecs() as needed. You can either completely rewrite the spec generation logic, or you can call the parent version of the function and then manipulate the array slightly to add, remove or reorder fields.+If you want to make global changes to a specification, the easiest solution is to extend [[https://github.com/vufind-org/vufind/blob/dev/module/VuFind/src/VuFind/View/Helper/Root/RecordDataFormatterFactory.php|\VuFind\View\Helper\Root\RecordDataFormatterFactory]] in your own [[development:architecture:customizing_vufind#modules|custom module]] and override getDefaultCoreSpecs() and/or getDefaultDescriptionSpecs() as needed. You can either completely rewrite the spec generation logic, or you can call the parent version of the function and then manipulate the array slightly to add, remove or reorder fields.
  
 ==== Option 2: Override the Template ==== ==== Option 2: Override the Template ====
Line 65: Line 69:
 If you want to change behavior for a specific record driver, or if you prefer to keep your code changes at a higher level, you can also customize the appropriate record driver template(s), simply manipulating the spec array between the call to getDefaults() and the call to getData(). If you want to change behavior for a specific record driver, or if you prefer to keep your code changes at a higher level, you can also customize the appropriate record driver template(s), simply manipulating the spec array between the call to getDefaults() and the call to getData().
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
development/architecture/record_data_formatter.txt · Last modified: 2023/12/11 16:11 by dltj