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
Last revisionBoth sides next revision
development:architecture:record_data_formatter [2023/10/12 18:38] – [Specification Array] demiankatzdevelopment:architecture:record_data_formatter [2023/11/17 19:11] – [Option 1: Use Configuration] demiankatz
Line 30: Line 30:
 | context | optional | An array of contextual values that may be used to help with template rendering; these are always passed through as the 'context' key of the output of the view helper. When template rendering (renderType = RecordDriverTemplate) is used, these values are also passed directly to the target template | | context | optional | An array of contextual values that may be used to help with template rendering; these are always passed through as the 'context' key of the output of the view helper. When template rendering (renderType = RecordDriverTemplate) is used, these values are also passed directly to the target template |
 | dataMethod | :!: required :!: | The record driver method to use for extracting raw field data used for generating output. May be set to boolean true to always generate output without variable input; may be set to boolean false to suppress the entire field. | | dataMethod | :!: required :!: | The record driver method to use for extracting raw field data used for generating output. May be set to boolean true to always generate output without variable input; may be set to boolean false to suppress the entire field. |
 +| dataMethodParams | optional | An array of values to pass to the dataMethod as arguments. Useful, for example,  to call getAllSubjectHeadings with $extended set to true. // Introduced in VuFind® 10.0. // |
 | helperMethod | optional | The Record view helper method to use for output rendering, when renderType = RecordHelper. | | helperMethod | optional | The Record view helper method to use for output rendering, when renderType = RecordHelper. |
 | pos | optional | An integer used for sorting the fields to determine the final display order. | | pos | optional | An integer used for sorting the fields to determine the final display order. |
Line 55: Line 56:
 Useful public methods: Useful public methods:
  
 +  * setCombineAltLine($key, $dataMethod, $options = []) - add a CombinedAlt configuration for $key; convenience method wrapped around setLine(), introduced in VuFind® 9.1
   * setLine($key, $dataMethod, $renderType = null, $options = []) - add a configuration for $key; defaults to 'Simple' $renderType   * setLine($key, $dataMethod, $renderType = null, $options = []) - add a configuration for $key; defaults to 'Simple' $renderType
   * setMultiLine($key, $dataMethod, $callback, $options = []) - add a multi-function-based configuration for $key; convenience method wrapped around setLine()   * setMultiLine($key, $dataMethod, $callback, $options = []) - add a multi-function-based configuration for $key; convenience method wrapped around setLine()
Line 61: Line 63:
 ===== Customizing Specifications ===== ===== Customizing Specifications =====
  
-There are two simple ways to change specifications.+There are three simple ways to change specifications.
  
-==== Option 1: Override the Factory ====+==== Option 1: Use Configuration ==== 
 + 
 +Starting in VuFind® 10.0, it is possible to customize record displays using [[https://github.com/vufind-org/vufind/blob/dev/config/vufind/RecordDataFormatter.ini|RecordDataFormatter.ini]] -- see the comments in that file for details and examples. Earlier releases require you to use one of the other two options below. 
 + 
 +==== Option 2: 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/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. 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 3: Override the Template ====
  
 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().
development/architecture/record_data_formatter.txt · Last modified: 2023/12/11 16:11 by dltj