2017 © Pedro Peláez
 

contao-module contao-selectri

A selection widget for large structured option sets.

image

backboneit/contao-selectri

A selection widget for large structured option sets.

  • Tuesday, August 4, 2015
  • by backbone87
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1,346 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

backboneit_selectri

A selection widget for large structured option sets., (*1)

Usage in DCA

Input type token: selectri, (*2)

eval Parameters

Value retrieval, (*3)

The widgets canonical representation of selection values are arrays that map selected nodes' keys to arrays containing the selected nodes' key at the array key _key as well as additional data associated with this selected node., (*4)

If you work with the widget directly, it is strongly recommended that you use the getValue/setValue methods, which will always return values in this canonical representation form., (*5)

If you however use this widget in DCAs, it is desired that the widget's value property (which is used by the DCA) is converted to - on retrieval - or converted from - on set - a specific format. To avoid the registration of load/save callbacks, the value property maintains an array of selected options' keys or, if max is set to 1, a single selected option's key. For commonly used conversions there exist the following eval properties to further modify the value's property content:, (*6)

  • findInSet - boolean - defaults to false, (*7)

    • get: Returns a comma-separated list of the selected options' keys. This behavior takes precedence over the canonical setting., (*8)

    • set: Strings are handled as comma-separated lists of selected options' keys and gets split at ,. A normalization to the canonical form is done after., (*9)

  • canonical - boolean - defaults to false, (*10)

    • get: Returns the canonical form of the selection or, if max is set to 1, only the selected option's data array., (*11)

    • set: A normalization to the canonical form is done., (*12)

Basic widget configuration, (*13)

  • min - integer, non-negative - defaults to 0, (*14)

    How many nodes must be selected at least., (*15)

    If the max parameter is less than the configured minimum, the min parameter will be considered equal to the configured maximum., (*16)

  • max - integer, positive - defaults to 1, (*17)

    How many nodes can be selected at most., (*18)

  • mandatory - boolean - optional - deprecated: the min parameter should be used, (*19)

    If given and true, the min parameter will be set to 1, if it is not > 0 already. If given and false, the min parameter will be set to 0., (*20)

  • multiple - boolean - optional - deprecated: the max parameter should be used, (*21)

    If given and true, the max parameter will be set to PHP_INT_MAX, if it is not > 1 already. If given and false, the max parameter will be set to 1., (*22)

  • searchLimit - integer, positive - defaults to 20, (*23)

    The max nodes retrieved from searches., (*24)

  • sort - string, one of list, preorder, tree - defaults to list, (*25)

    The structure implied on the made selection, (*26)

    • list: the selection is a list (order matters), the selection is sortable
    • preorder not implemented: the selection is a set (order does not matter), the selection is not sortable and preordered
    • tree not implemented: the selection is a tree, the selection can be arranged with tree properties
  • height - string - defaults to auto, (*27)

    The CSS value and unit of the CSS height property of the selection tree., (*28)

  • tl_class - string - optional, (*29)

    Only used in Backend., (*30)

  • class - string - optional, (*31)

    Use this to apply your custom CSS savely. You can use "radio" or "checkbox" to replace the Contao-style select (+) and deselect (x) icons with Windows legacy input-like icon images., (*32)

  • data - string or an object implementing SelectriDataFactory - defaults to the string SelectriContaoTableDataFactory, (*33)

    If a factory object is given, these factory will be used to generate a data instance for created widgets. The setParameters method is not called. This is the recommended way to provide a SelectriData, as all data implementation specific features and options can be properly configured through their factories., (*34)

    If a string is given, it must name a class implementing SelectriDataFactory. When creating the widget, a new factory instance is created and its setParameters method is called with the attributes of the widget (the widget's attributes contains all settings from the DCA's eval array)., (*35)

Factory specific configuration (used by setParameters method of the SelectriDataFactory class given in the data parameter), (*36)

  • treeTable - string - optional, (*37)

    The name of the table to fetch tree nodes from., (*38)

    The parameter is used by SelectriContaoTableDataFactory::setParameters method and preconfigures the data according to common Contao standards like primary key column id and parent key column pid., (*39)

  • mode - string - defaults to all, (*40)

    The parameter is used by SelectriTableDataFactory::setParameters method., (*41)

    • all: all nodes are selectable
    • leaf: only leaf nodes are selectable
    • inner: only inner nodes are selectable

Simple example for usage in DCA

$GLOBALS['TL_DCA']['tl_mydca']['fields']['mySelectriField'] = array(
    ...
    'inputType' => 'selectri',
    ...
    'eval' => array(
        // all values are the defaults
        'min'               => 0,           // the selection can be empty
        'max'               => 1,           // let the user select not more than 1 item
        'searchLimit'       => 20,          // max search results
        'findInSet'         => false,       // dont use csv
        'additionalInput'   => false,       // no additional inputs via node content callback is injected
        'sort'              => 'list',
        'height'            => 'auto',      // the height of the tree widget
        'tl_class'          => 'clr',       // some css-classes,
        'class'             => '',          // use "radio" or "checkbox" to replace the icons
        'data'              => 'SelectriContaoTableDataFactory', // the data factory class to use
        'treeTable'         => 'tl_page',   // a DB-table containing the tree structure (Contao-like adjacency list)
        'mode'              => 'all',       // which nodes are selectable: "all", "leaf", "inner"
    ),
    ...
);

Advanced example for usage in DCA

Instead of using a implicit created factory instance by providing a factory class name in the previous example, you can preconfigure your own factory instance and have full access to all parameters used by the SelectriData-class produced by the factory., (*42)

$data = SelectriContaoTableDataFactory::create();

// use the tl_page table for the tree structure
$data->setTreeTable('tl_page');

// show all nodes
$data->getConfig()->setTreeMode('all');

// search the title and pageTitle column
$data->getConfig()->setTreeSearchColumns(array('title', 'pageTitle'));

// only show nodes matching the condition
$data->getConfig()->setTreeConditionExpr('type = \'regular\' AND tstamp > 0');

// only let the user select nodes matching the condition
$data->getConfig()->setSelectableExpr('hide <> \'1\'');

// for more parameters see the factory class and the underlaying config class

$GLOBALS['TL_DCA']['tl_mydca']['fields']['mySelectriField'] = array(
    ...
    'inputType' => 'selectri',
    ...
    'eval' => array(
        'min'           => 0,
        'max'           => 1,
        'searchLimit'   => 20,
        'tl_class'      => 'clr',
        'class'         => 'checkbox',

        // assign your preconfigured factory instance to the widgets configuration
        'data'          => $data,
    ),
    ...
);

The Versions

04/08 2015

2.x-dev

2.9999999.9999999.9999999-dev

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

30/07 2014

2.0.2

2.0.2.0

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

30/07 2014

1.x-dev

1.9999999.9999999.9999999-dev

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

17/04 2014

2.0.1

2.0.1.0

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

04/04 2014

2.0.0

2.0.0.0

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

04/04 2014

1.1.0

1.1.0.0

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao

28/03 2014

1.0.0

1.0.0.0

A selection widget for large structured option sets.

  Sources   Download

LGPL-3.0+

The Requires

 

widget select tree contao