在一个项目中我使用的是TYPO3 Extension DCE(动态内容元素)。使用DCE,您无需编写扩展名即可创建自己的动态内容元素。
创建内容对象后,您可以使用FLUID访问创建的内容元素。
到目前为止一切顺利。一切都很完美。
现在我的问题:
我需要访问DCE中的变量 - 带有Typoscript的元素,如下所示:
10 = TEXT
10 {
field = referenceCustomer
wrap = <span class="referenceCustomer">|</span>
}
字段referenceCustomer之前由DCE创建。使用FLUID,我可以使用
访问该字段{field.referenceCustomer}
我真的不知道如何访问生成的字段..
但是最重要的是,我能够访问我在Typoscript中使用DCE创建的FAL图像字段。
此代码有效:
10 = FILES
10 {
references {
table = tt_content
uid.field = uid
fieldName = referenceImages
}
begin = 0
maxItems = 1
renderObj = IMAGE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 365c
height = 125c
}
altText.data = file:current:title
titleText.data = file:current:title
}
}
也许你可以帮助我.. 我看不到树木了。
答案 0 :(得分:0)
为了将这个问题标记为已解决,我将自己发布答案。
我制作了一个PHP Userfunc。 UserFunc能够读取FlexForm值。
这是我的解决方案:
Typoscript对象:
includeLibs.FlexformValue = fileadmin/templates/Utility/UserFunc/FlexformValue.php
5 = USER
5 {
userFunc = FlexformValue->field
userFunc {
uid = TEXT
uid {
field = uid
}
field = referenceCustomer
}
}
所需的PHP UserFunc:
<?php
/***************************************************************
* 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!
***************************************************************/
class FlexformValue {
function field($content, $conf) {
$conf = $conf['userFunc.'];
$uid = $this->cObj->stdWrap($conf['uid'], $conf['uid.']);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pi_flexform', 'tt_content', 'uid = ' . $uid);
$flexform = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array(current($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)));
$this->temporaryDceProperties = array();
if(is_array($flexform)) {
$this->getVDefValues($flexform, $this);
}
return $this->temporaryDceProperties[$conf['field']];
}
/**
* Flatten the given array and extract all vDEF values. Result is stored in $this->dceProperties.
*
* @param array $array flexform data array
* @param Object $caller
* @param null|string $arrayKey
* @return void
*/
public function getVDefValues(array $array, $caller = NULL, $arrayKey = NULL) {
if ($caller === NULL) {
$caller = $this;
}
foreach($array as $key => $value) {
if ($key === 'vDEF') {
$caller->temporaryDceProperties[substr($arrayKey, 9)] = $value;
}
elseif (is_array($value) && array_key_exists('el', $value)) {
$propertyName = substr($key, 9);
$values = array();
$i = 1;
if (is_array(current($value))) {
foreach (current($value) as $entry) {
if (is_array($entry)) {
$entry = $entry['container_' . $propertyName]['el'];
if (is_array($entry)) {
foreach($entry as $k => $v) {
$entry[$k] = $v['vDEF'];
}
$values[$i++] = array('container_' . $propertyName => $entry);
}
}
}
}
$caller->temporaryDceProperties[$propertyName] = $values;
} elseif (is_array($value)) {
$this->getVDefValues($value, $caller, $key);
}
}
}
}
我希望这个答案可以帮助那些遇到同样问题的人。
问题解决了。