Hallo!
Hätte eine Frage zu der TCA-Tabelle. Kann man dort auch weitere oder ein anderes Feld als den title angeben, die dann in der Auswahlliste angezeigt werden? Soetwas wie z.B. beim TS-Befehl select die selectFields-Funktion.
$tempColumns = Array (
"tx_commercerelated_related_products" => Array (
"exclude" => 1,
"label" => "LLL:EXT:commercerelated/locallang_db.xml:tx_commerce_products.tx_commercerelated_related_products",
"config" => Array (
'type' => 'select',
'internal_type' => 'db',
'allowed' => 'tx_commerce_products',
'MM' => 'tx_commerce_products_tx_commercerelated_related_products_mm',
'foreign_table' => 'tx_commerce_products',
'foreign_table_where' => ' ORDER BY tx_commerce_products.sorting',
'size' => 15,
'minitems' => 0,
'maxitems' => 99,
)
),
);
Hoffe einer weiß Rat.
lg lixx
es gilt immer das label das bei der Tabelle im TCA steht.
In Deinem Beispiel das label das für tx_commerce_products definiert ist.
Abweichend geht nur in einer labelUserFunc oder die komplette select in einer userFunc
Ja, danke! Hat weitergeholfen.
lg lixx
Hi steffenk,
hast Du für deinen Lösungsansatz mit der userFunc ein Beispiel. Ich benötige in einer Selectbox mehr Angaben als nur ein Feld, also z.B. Vorname - Nachname statt nur den Nachnamen. Habe hier auch schon lange gesucht, nur leider bis jetzt nicht fündig geworden.
Danke
Gruß
febo
Nein 😉 aber ich hab' eins gerade zur Hand:
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
$tempColumns = Array (
"tx_commercerelated_related_products" => Array (
"exclude" => 1,
"label" => "LLL:EXT:commercerelated/locallang_db.xml:tx_commerce_products.tx_commercerelated_related_products",
"config" => Array (
'type' => 'select',
'internal_type' => 'db',
'allowed' => 'tx_commerce_products',
'MM' => 'tx_commerce_products_tx_commercerelated_related_products_mm',
'foreign_table' => 'tx_commerce_products',
'foreign_table_where' => " AND tx_commerce_products.uid != '###THIS_UID###' ORDER BY tx_commerce_products.sorting",
'size' => 15,
'minitems' => 0,
'maxitems' => 99,
'itemsProcFunc' => 'user_commercerelated_selection',
)
),
);
t3lib_div::loadTCA("tx_commerce_products");
t3lib_extMgm::addTCAcolumns("tx_commerce_products",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes("tx_commerce_products","tx_commercerelated_related_products;;;;1-1-1");
t3lib_extMgm::addStaticFile($_EXTKEY,'static/defaults/', 'defaults');
function user_commercerelated_selection(&$conf,&$item) {
if (isset($conf['items'])) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('subtitle', $conf['config']['foreign_table'], '1'.str_replace('###THIS_UID###', $conf['row']['uid'], $conf['config']['foreign_table_where']));
while ($row[] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res));
foreach ($conf['items'] as $x => $val) {
$conf['items'][$x][0] .= $row[$x]['subtitle'] ? ', '.$row[$x]['subtitle'] : '';
}
}
return $conf;
}
?>
Verwendet mit der ext commercerelated.
Zeile 17 wird die Funktion definiert.
Zeile 29 beginnt die User-Function.
In der Variable $conf ist dann der aktuelle Datensatz zu finden. Aber erst beim zweiten Durchlauf ... warum weiß ich auch nicht ... daher noch die Abfrage "if (isset($conf['items']))"
lg lixx
Das Beispiel ist aber für itemsProcFunc
Ein Beispiel für labelUserFunc befindet sichj in cal in class.tx_cal_labels.php
$TCA['tx_cal_event']['ctrl']['label_userFunc']="tx_cal_labels->getEventRecordLabel";
Es geht doch um das Item und nicht das Label, oder? Das Label ist doch die Überschrift einer Selectbox.
und ...
$TCA['tx_cal_event']['ctrl']
... betrifft ja alle Felder der Tabelle.
febo fragte nach dem Beispiel, und in dem Beispiel das lable für cal events (Liste oder sonst wo)