我使用Extension Builder在TYPO3 6.2上创建了自己的扩展程序,目标是让后端用户创建我们公司的事件(包括姓名,地点,日期,人数......等)。
怎么做?
在我的ext_localconf.php中,我有:
<?php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Mycompany.' . $_EXTKEY,
'Displayevent',
array(
'Event' => 'show',
),
// non-cacheable actions
array(
'Event' => 'show',
)
);
?>
但是在前端有一个Typo3错误:
1298012500:必填参数&#34;事件&#34;没有为Mycompany \ MycompanyEvents \ Controller \ EventController-&gt; show
设置
这里我的showAction()代码:
/**
* action show
*
* @param \MyCompany\mycompany_events\Domain\Model\Event $event
* @return void
*/
public function showAction(\MyCompany\mycompany_events\Domain\Model\Event $event) {
$this->view->assign('event', $event);
}
答案 0 :(得分:1)
尝试按照以下步骤调用flexform。
在ext_tables.php
文件中添加以下代码。
//extenstion name
$extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY);
//plugin integration
$frontendpluginName = 'your_plugin_name';
$pluginSignature = strtolower($extensionName) . '_'.strtolower(
$frontendpluginName
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/configure_plugin.xml'
);
现在,在此目录/Configuration/FlexForms/
中创建flexform文件,如下所示,并使用userFunct作为事件选择列表。
<T3DataStructure>
<sheets>
<!--
################################
SHEET General Settings
################################
-->
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>General</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.variable_name>
<TCEforms>
<label>Title</label>
<config>
<type>select</type>
<itemsProcFunc>EXT:ext_key/Classes/Utility/class.tx_event_utility.php:tx_event_utility->getEventList</itemsProcFunc>
<multiple>0</multiple>
<minitems>0</minitems>
<maxitems>50</maxitems>
<size>5</size>
</config>
</TCEforms>
</settings.variable_name>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
现在,在此路径tx_event_utility.php
上创建/ext_key/Classes/Utility/
文件,如下所示。
<?php
class tx_event_utility {
protected $objectManager;
protected $configurationManager;
protected $pluginSetting;
protected $objectCategoryRepository;
function __construct() {
$this->objectManager = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
$this->pluginSetting = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$this->objectCategoryRepository = $this->objectManager->get('added repositry namespace');
}
function getEventList($config, $item) {
// write code for geting event list
}
return $config;
}
}
?>
答案 1 :(得分:0)
添加文件Yourext / Configuration / TCA / Overrides / tt_content.php
<?php
defined('TYPO3_MODE') or die();
// register plugin and flexform
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'yourext',
'Name',
'LLL:EXT: yourext/Resources/Private/Language/locallang_be.xlf:name_plugin'
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['yourext_name'] = 'select_key';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['yourext_name'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
'yourext_name',
'FILE:EXT:yourext/Configuration/FlexForms/flexform.xml'
);