TYPO3 - 自定义扩展程序:以flexform

时间:2017-12-29 11:09:02

标签: typo3 typo3-6.2.x typo3-extensions

我使用Extension Builder在TYPO3 6.2上创建了自己的扩展程序,目标是让后端用户创建我们公司的事件(包括姓名,地点,日期,人数......等)。

  • 我创建了一个后端插件,效果很好。
  • 我创建了一个前端插件,但我不知道如何编写我的flexform文件,以便让后端用户选择要显示的事件(通过"显示& #34;行动我想)...最好的结果是获得包含所有现有事件的选择列表。

怎么做?

在我的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);
}

2 个答案:

答案 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'
);
相关问题