TypoScript Configuration

Every part of the extension can be configured using TypoScript.

The Demander extension’s TypoScript configuration is made at config.tx_demander. The configuration has four main properties:

  • demandProviders: An array of DemandProvider class names.
  • properties: An array of demand property definitions, roughly equivalent to database fields to filter by.
  • demands: Pre-defined demands processed using Pixelant\Demander\DemandProvider\TypoScriptDemandProvider.
  • ui: Configuration for frontend UI components.
  • There are also a limited number of other properties.

demandProviders

An array of DemandProvider class names. Each provider fetches demand information from a source and must implement Pixelant\Demander\DemandProvider\DemandProviderInterface.

  • TypoScriptDemandProvider: Fetches demands from config.tx_demander.demands.
  • RequestDemandProvider: Fetches demands from the body (POST data) of an HTTP request. The property values are fetched from the key d, e.g. $request->getQueryParams()['d']['myProperty'].

Each DemandProvider is ordered by the numeric key. Higher keys override values from lower keys. All :php:`DemandProvider`s are always processed.

demandProviders {
  40 = Pixelant\Demander\DemandProvider\RequestDemandProvider
  50 = Pixelant\Demander\DemandProvider\TypoScriptDemandProvider
}

properties

This array defines demand properties. That is, the array keys used by the Demander extension and how to make their values into filtering restrictions in the database.

Example

In this example a demand for d[myProperty]=6 will filter for records with points less than 6 and type set to 5.

properties {
  myProperty {
    table = tx_myextension_record
    field = points
    operator = <

    additionalRestriction {
      tx_myextension_record-type {
        operator = =
        value = 5
      }
    }
  }
}

The resulting SQL restriction looks like:

tx_myextension_record.points < 6 AND tx_myextension_record.type = 5

Properties

Properties within config.tx_demander.properties.<propertyName>.

table

Property
table
Data type
string
Description
The table name to apply the restriction to.

field

Property
field
Data type
string
Description
The field name to apply the restriction to.

operator

Property
operator
Data type
= / > / >= / < / <= / - / in
Description

The operator to use for comparison.

  • =: Equals
  • >: Greater than
  • >=: Greater than or equal to
  • <: Less than
  • <=: Less than or equal to
  • -: Between or equal to two values. The demand value must always be an array with two keys (min and max) containing the minimum and maximum values to use in the comparison.
  • in: The value must be one of the values in an array. The demand value must always be an array of values.

additionalRestriction

Property
additionalRestriction
Data type
array
Description

Additoinal restrictions to apply, for example if the filter applies to a certain record type only. Contains an array of table-field definition arrays with key <tablename>-<fieldname>. Available properties are:

  • operator: The restriction operator, see operator.
  • value: The value to apply to the restriction.

Example:

additionalRestriction {
  tx_myextension_record-type {
    operator = =
    value = 5
  }
}

Configures this additional restriction:

tx_myextension_record.type = 5

demands

Properties within config.tx_demander.demands.<propertyName>|and|or.

Contains pre-defined, static demands processed using Pixelant\Demander\DemandProvider\TypoScriptDemandProvider. Compared to most other demand providers, these demands will always be applied because they are statically defined in TypoScript.

The keys can either be a property name or a conjunction (and or or). The conjunction wraps another demand array, joining the restrictions using the conjunction, rather than the default.

demands {
  myProperty = 6
  or {
    aRangeProperty = 1-5
    aListProperty = 1,7,4
  }
}

Property names contain the Demand extension’s standard demand data definition, i.e. <propertyName>=<value>.

The accepted values depend on the property operator:

  • =: One string or scalar value.

  • >: Scalar value.

  • >=: Scalar value.

  • <: Scalar value.

  • <=: Scalar value.

  • -: A range of scalar values with lowest and highest separated with a dash (i.e. <lowest>-<highest>, e.g. 1-5).

  • in: A comma-separated list of values or a TypoScript array of values.

    Comma-separated list:

    aListProperty = 1,7,4
    

    TypoScript array of values:

    aListProperty {
      10 = gold
      20 = silver
      30 = bronze
    }
    

ui

Properties within config.tx_demander.ui.<propertyName> define the behavior of UI filter components used to create demands based on user input. Such components could be a text field, a drop-down menu, a list of checkboxes, or a slider.

Example

This example defines a drop-down menu with three options.

ui {
  myProperty {
    label = My Property
    type = select
    values {
      a = Option A
      b = Option B
      c = Option C
    }
  }
}

Properties

label

Property
label
Data type
string
Description
The UI component label. Also supports localization paths like LLL:EXT:myextension/Resources/Private/Language/locallang.xml:labelKey.

type

Property
type
Data type
text / rangeText / select / checkbox / checkboxes / slider / rangeSlider
Description

The type of UI element to render.

  • text: A text field
  • rangeText: Two text fields for defining numeric minimum and maximum values
  • select: A drop-down menu
  • checkbox: A checkbox (can only have one value)
  • checkboxes: A list of checkboxes
  • slider: A slider
  • rangeSlider: A slider with two knobs for defining minimum and maximum values

values

Property
values
Data type
array
Description

An array of one or more values values used in select, checkbox (only one value allowed), and checkboxes. Defined as <value>=<label>.

values {
  a = Option A
  b = Option B
  c = Option C
}

Other Properties

Property
defaultConjunction
Data type
and / or
Default value
and
Description
The conjunction to use for demands. The default is to use and, which means results will match all demands. If set to or the results will match any of the demands.