菜单

Record tree for TCA

2011年04月5日 - extensions

Extension Key: cps_tcatree required plugin: Developer library ( cps_devlib )

Installation / Quick start

Changes in ext_tables.php

For each table you want to display as a tree you have to define a new key “treeParentField” which defines the field in which the relation is stored. This field can be either a comma separated list of uids or a mm-relation field.

Example

To use pages as a tree just insert following code:

t3lib_div::loadTCA('pages');
$TCA['pages']['ctrl']['treeParentField'] = 'pid';

When you want to use your own (extension) records just insert something like:

$TCA['tx_cpstestcase_pagetree'] = array (
 'ctrl' => array (
 'title' => 'LLL:EXT:cps_testcase/locallang_db.xml:tx_cpstestcase_pagetree',
 'label' => 'title',
 'tstamp' => 'tstamp',
 'crdate' => 'crdate',
 'cruser_id' => 'cruser_id',
 'default_sortby' => 'ORDER BY crdate',
 'delete' => 'deleted',
 'enablecolumns' => array (
 'disabled' => 'hidden',
 ),
 'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
 'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'icon_tx_cpstestcase_pagetree.gif',
 'treeParentField' => 'testref',
 ),
);

Changes in tca.php

Each field you want to display as tree needs some additional configuration. Please find attached an overview of properties you have to set. You can use the function with comma separated fields and MM-relation fields.

Property: Data type: Description: Default:
form_type
string
[Must be set to “user”]

userFunc
string
[Must be set to “tx_cpstcatree->getTree”

treeView
boolean
Either ahow items in a tree or among each other

expandable
boolean
Either use JavaScript to expand/collaps tree (otherwise all items are display among themselves)

expandFirst
boolean
Expand the first item in tree

expandAll
boolean
Expand all items in tree

trueMaxItems
integer
To use type=”select” as selectorbox with two fields maxitems needs to be greater than 2. If you want to allow only one maxitems you have to use this field which overrides maxitems after selectorbox is created

Example

'pageref' => array (
 'exclude' => 0,
 'label' => 'LLL:EXT:cps_testcase/locallang_db.xml:tx_cpstestcase_pagetree.pageref',
 'config' => array (
 'type' => 'select',
 'form_type' => 'user',
 'userFunc' => 'tx_cpstcatree->getTree',
 'foreign_table' => 'pages',
 'treeView' => 1,
 'expandable' => 1,
 'expandFirst' => 0,
 'expandAll' => 0,
 'size' => 1,
 'minitems' => 0,
 'maxitems' => 2,
 'trueMaxItems' => 1,
 )

发表评论

电子邮件地址不会被公开。 必填项已用*标注