를 (이 코드가 작동하지 않습니다)입니다 수 있습니다. 귀하의 경우에는
나는 당신의 TCA 구성에 대한 권장합니다
'checkbox' => [
'displayCond' =>'USER:VendorName\\Myext\\DisplayConditionMatcher->displayIfTxMyextObjectHasNoMMRelation',
'exclude' => 1,
'label' => 'Checkbox',
'config' => [
'type' => 'check',
'default' => 0
]
],
그리고 당신의 확장 EXT에 위치한 DisplayConditionMatcher.php라는 이름의 PHP 클래스 : myext/클래스/다음과 같은 내용으로 :
<?php
namespace VendorName\Myext;
/**
* Class DisplayConditionMatcher
*
* @package TYPO3
* @subpackage tx_myext
* @author 2016 J.Kummer <typo3 et enobe dot de>
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class DisplayConditionMatcher {
/**
* Checks for already existing mm relation of tx_myext_object
* Returns true, if no mm relation found
*
* @param array $configuration
* @param \TYPO3\CMS\Backend\Form\FormDataProvider\EvaluateDisplayConditions $evaluateDisplayConditions
* @return bool
*/
public function displayIfTxMyextObjectHasNoMMRelation(array $configuration, $evaluateDisplayConditions = null)
{
$result = true;
if (isset($configuration['record']['uid'])) {
$countRows = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
'uid_foreign',
'tx_myext_object_object_mm',
'uid_foreign = ' . intval($configuration['record']['uid'])
);
if ($countRows > 0) {
$result = false;
}
}
if (isset($configuration['conditionParameters'][0]) && $configuration['conditionParameters'][0] === 'negate') {
$result = !$result;
}
return $result;
}
}
TYPO3 CMS TCA Reference에 설명 된대로 userFunc 유형의 displayCondition에 콜론으로 구분 된 추가 매개 변수를 전달할 수 있습니다. 이미 PHP 클래스에서 구현 예를 들어, 부정의 경우 :
'displayCond' =>'USER:VendorName\\Myext\\DisplayConditionMatcher->displayIfTxMyextObjectHasNoMMRelation:negate',
은 당신의 필요에 맞는 확장, 경로 및 공급 업체의 이름을 적응.
IN에는 값이 필요합니다. 어쩌면 당신은 당신의 쿼리 문으로 사용자 함수를 사용해보십시오. https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html?#displaycond – jokumer
@jokumer 이것은 1 단계 유용합니다. 초보자를위한 더 많은 코드/예제가 있습니까? 나는 사용자 함수 나 사용자 함수를 사용하는 문법을 보지 못했다. 이것은 당신이 준 참조에 없다. – webMan