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.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:architecture:record_data_formatter [2023/10/12 18:36] – [Specification Array] demiankatz | development:architecture:record_data_formatter [2023/12/11 16:11] (current) – [Option 2: Override the Factory] Add example of re-ordering spec array dltj | ||
---|---|---|---|
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 | optional | An array of contextual values that may be used to help with template rendering; these are always passed through as the ' | ||
| 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, | ||
| 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 46: | Line 47: | ||
| translationTextDomain | optional (default = '' | | translationTextDomain | optional (default = '' | ||
| useCache | optional (default = false) | Should we cache the raw field data in the view helper to avoid duplicate calls? | | | useCache | optional (default = false) | Should we cache the raw field data in the view helper to avoid duplicate calls? | | ||
+ | | altDataMethod | optional (default = dataMethod value + " | ||
| combineAltRenderType | optional (default = Simple) | Render type used for values when renderType is set to CombineAlt. :!: // Introduced in VuFind® 9.1. // | | | combineAltRenderType | optional (default = Simple) | Render type used for values when renderType is set to CombineAlt. :!: // Introduced in VuFind® 9.1. // | | ||
+ | | combineAltTemplate | optional (default = combine-alt) | Name of template for rendering side-by-side values when renderType is set to CombineAlt. :!: // Introduced in VuFind® 9.1. // | | ||
===== The Specification Builder ===== | ===== The Specification Builder ===== | ||
Line 53: | Line 56: | ||
Useful public methods: | Useful public methods: | ||
+ | * setCombineAltLine($key, | ||
* setLine($key, | * setLine($key, | ||
* setMultiLine($key, | * setMultiLine($key, | ||
Line 59: | 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 |
- | If you want to make global changes to a specification, the easiest solution | + | Starting in VuFind® 10.0, it is possible |
- | ==== Option 2: Override the Template ==== | + | ==== Option 2: Override the Factory ==== |
+ | |||
+ | If you want to make global changes to a specification, | ||
+ | |||
+ | <code PHP> | ||
+ | class RecordDataFormatterFactory extends \VuFind\View\Helper\Root\RecordDataFormatterFactory | ||
+ | { | ||
+ | public function getDefaultCoreSpecs() | ||
+ | { | ||
+ | $spec = new SpecBuilder(parent:: | ||
+ | $specArray = $spec-> | ||
+ | $specArray[' | ||
+ | $specArray[' | ||
+ | return $specArray; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In the parent:: | ||
+ | ==== 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), | 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), |
development/architecture/record_data_formatter.1697135784.txt.gz · Last modified: 2023/10/12 18:36 by demiankatz