Wert aus Flexform per TS lesen
Armin Bartsch, Dienstag, 10. März 2009
Zur Zeit ist es nicht möglich per TS ein Flexform-Werte direkt auszulesen. Eine kleine USER-Funktion macht dies aber möglich
Damit die umfangreiche Konfigurationsmöglichkeit von TYPO3 weiter genutzt werden kann, wird zum auslesen des Datensatz aus das CObject RECORDS und für den Flexformwertes auf USER zurückgegriffen.
TypoScript
# Hier müssen Sie evtl. den Pfad zur flexform_order.php anpassen
includeLibs.flexform_order_pi = fileadmin/flexform_order.php
temp.flexform = RECORDS
temp.flexform {
tables = tt_content
source = 214
conf.tt_content = COA
conf.tt_content {
10 = USER
10 {
userFunc = user_flexform_order_pi->field
# Name des Feldes mit Flexform (XML)
field = tx_templavoila_flex
# Name des FlexForm-Data
flex_data = field_a69d3f
# Sheet Pointer, standard ist sDEF
sheet_pointer = sDEF
# Sprache, standard ist lDEF
lang = lDEF
# Value, standard = vDEF
value_def = vDEF
}
}
}
lib.footer.2221 < temp.flexform# Hier müssen Sie evtl. den Pfad zur flexform_order.php anpassen
includeLibs.flexform_order_pi = fileadmin/flexform_order.php
temp.flexform = RECORDS
temp.flexform {
tables = tt_content
source = 214
conf.tt_content = COA
conf.tt_content {
10 = USER
10 {
userFunc = user_flexform_order_pi->field
# Name des Feldes mit Flexform (XML)
field = tx_templavoila_flex
# Name des FlexForm-Data
flex_data = field_a69d3f
# Sheet Pointer, standard ist sDEF
sheet_pointer = sDEF
# Sprache, standard ist lDEF
lang = lDEF
# Value, standard = vDEF
value_def = vDEF
}
}
}
lib.footer.2221 < temp.flexform
USER - Funktion
Jetzt erstellen die eine PHP-Datei mit folgenden Inhalt:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2006 Armin Bartsch http://typo3.intervation.de
* All rights reserved
*
* This script is part of the Typo3 project. The Typo3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
require_once(PATH_tslib.'class.tslib_pibase.php');
class user_flexform_order_pi extends tslib_pibase {
function field($content, $conf) {
$this->pi_loadLL();
$this->pi_setPiVarDefaults();
$this->pi_initPIflexForm();
$flex_array = t3lib_div::xml2array($this->cObj->data[''.$conf['field'].'']);
$tv_field = $this->pi_getFFvalue($flex_array, $conf['flex_data'], $conf['sheet_pointer'], $conf['lang'], $conf['value_def']);
return $tv_field;
}
}
?><?php
/***************************************************************
* Copyright notice
*
* (c) 2006 Armin Bartsch http://typo3.intervation.de
* All rights reserved
*
* This script is part of the Typo3 project. The Typo3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
require_once(PATH_tslib.'class.tslib_pibase.php');
class user_flexform_order_pi extends tslib_pibase {
function field($content, $conf) {
$this->pi_loadLL();
$this->pi_setPiVarDefaults();
$this->pi_initPIflexForm();
$flex_array = t3lib_div::xml2array($this->cObj->data[''.$conf['field'].'']);
$tv_field = $this->pi_getFFvalue($flex_array, $conf['flex_data'], $conf['sheet_pointer'], $conf['lang'], $conf['value_def']);
return $tv_field;
}
}
?>