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

This is an old revision of the document!


RecordDataFormatter view helper

VuFind includes a RecordDataFormatter view helper designed to make it easier to customize the contents of tabular displays of data generated from record driver objects.

Basic Concept

The RecordDataFormatter's most important public method is getData(), which accepts two things as input:

  • A specification, in the form of an associative array, describing the fields of the output table and how to obtain the necessary data to populate them.
  • A record driver object.

As output, getData() returns an associative array of field name => HTML output for the corresponding field. Field names are raw and should be translated/escaped when displayed in templates.

Additionally, the helper includes getDefaults($key) / setDefaults($key) methods which can be used to store or retrieve default specification arrays. VuFind ships with stored specifications for 'core' and 'description', which are used in the corresponding .phtml files in the record driver template directory. See below on how to change/customize these defaults.

Customizing Specifications

There are two simple ways to change specifications.

Option 1: Override the Factory

If you want to make global changes to a specification, the easiest solution is to extend \VuFind\View\Helper\Root\RecordDataFormatterFactory in your own 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

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.1480606339.txt.gz · Last modified: 2016/12/01 15:32 by demiankatz