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:30] – 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. | | ||
- | | renderType | optional (default = Simple) | The method used to render output from the input provided by dataMethod. Legal values: **Multi** (sort data using a callback function specified by the ' | + | | renderType | optional (default = Simple) | The method used to render output from the input provided by dataMethod. Legal values: |
| labelFunction | optional | May be set to a callback function which will receive the raw field data as input and produce a custom output label (overriding the key of the spec array) as output. Starting with VuFind® 5.0, the callback function also receives the record driver object as a second parameter. | | | labelFunction | optional | May be set to a callback function which will receive the raw field data as input and produce a custom output label (overriding the key of the spec array) as output. Starting with VuFind® 5.0, the callback function also receives the record driver object as a second parameter. | | ||
| multiFunction | optional | The callback required when renderType = Multi. Accepts three parameters: 1.) raw input data, 2.) the options array from the spec, 3.) the record driver object. Outputs an array of associative arrays with the following keys: **label**: Label to display; **values**: Values to render; **options**: | | multiFunction | optional | The callback required when renderType = Multi. Accepts three parameters: 1.) raw input data, 2.) the options array from the spec, 3.) the record driver object. Outputs an array of associative arrays with the following keys: **label**: Label to display; **values**: Values to render; **options**: | ||
| multiRenderType | optional | The default type of rendering to apply to each of the sets of values returned by the multiFunction (optional, defaults to Simple, may be overridden by options specified by your multiFunction). | | | multiRenderType | optional | The default type of rendering to apply to each of the sets of values returned by the multiFunction (optional, defaults to Simple, may be overridden by options specified by your multiFunction). | | ||
| itemPrefix | optional | HTML to prepend to each value formatted by the view helper. Use prefix instead if you want to prepend a single value to the whole set of data assembled by the view helper. Applies only when RenderType = Simple. :!: // Introduced in VuFind® 7.0. // | | | itemPrefix | optional | HTML to prepend to each value formatted by the view helper. Use prefix instead if you want to prepend a single value to the whole set of data assembled by the view helper. Applies only when RenderType = Simple. :!: // Introduced in VuFind® 7.0. // | | ||
+ | | itemSuffix | optional | HTML to append to each value formatted by the view helper. Use suffix instead if you want to append a single value to the whole set of data assembled by the view helper. Applies only when RenderType = Simple. :!: // Introduced in VuFind® 7.0. // | | ||
| prefix | optional | HTML to prepend to the output generated by the view helper. This is applied once before the full set of values; use itemPrefix if you want to prepend something to each individual value. Applies only when RenderType = Simple. | | | prefix | optional | HTML to prepend to the output generated by the view helper. This is applied once before the full set of values; use itemPrefix if you want to prepend something to each individual value. Applies only when RenderType = Simple. | | ||
| recordLink | optional | The type of link (from the Record view helper' | | recordLink | optional | The type of link (from the Record view helper' | ||
| separator | optional (default = < | | separator | optional (default = < | ||
- | | itemSuffix | optional | HTML to append to each value formatted by the view helper. Use suffix instead if you want to append a single value to the whole set of data assembled by the view helper. Applies only when RenderType = Simple. :!: // Introduced in VuFind® 7.0. // | | ||
| suffix | optional | HTML to append to the output generated by the view helper. This is applied once after the full set of values; use itemSuffix if you want to append something to each individual value. Applies only when RenderType = Simple. | | | suffix | optional | HTML to append to the output generated by the view helper. This is applied once after the full set of values; use itemSuffix if you want to append something to each individual value. Applies only when RenderType = Simple. | | ||
| template | optional | The name of the template to render, when renderType = RecordDriverTemplate | | | template | optional | The name of the template to render, when renderType = RecordDriverTemplate | | ||
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. // | | ||
+ | | 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: Use Configuration ==== | ||
+ | |||
+ | Starting in VuFind® 10.0, it is possible to customize record displays using [[https:// | ||
+ | |||
+ | ==== Option 2: Override the Factory ==== | ||
- | ==== Option 1: Override | + | If you want to make global changes to a specification, |
- | If you want to make global changes to a specification, | + | <code PHP> |
+ | class RecordDataFormatterFactory | ||
+ | { | ||
+ | public function getDefaultCoreSpecs() | ||
+ | { | ||
+ | $spec = new SpecBuilder(parent:: | ||
+ | $specArray = $spec-> | ||
+ | $specArray[' | ||
+ | $specArray[' | ||
+ | return $specArray; | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
- | ==== Option | + | In the parent:: |
+ | ==== Option | ||
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.1697135417.txt.gz · Last modified: 2023/10/12 18:30 by demiankatz