1
votes

I made my own extension on TYPO3 6.2 with the Extension Builder, the goal is to let the backend users create events (with name, location, date, number of people etc...) of our company.

  • I created a backend plugin, it works good.
  • I created a frontend plugin, but I don't know how to write my flexform file in order to let the backend users choose which event to display (through the "show" action I guess)... Best result would be to get a select list with all existing events.

How to do it ?

In my ext_localconf.php, I have :

<?php

    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'Mycompany.' . $_EXTKEY,
        'Displayevent',
        array(
            'Event' => 'show',
            
        ),
        // non-cacheable actions
        array(
            'Event' => 'show',
            
        )
    );
    
?>

but in frontend there is a Typo3 error :

1298012500: Required argument "event" is not set for Mycompany\MycompanyEvents\Controller\EventController->show

here my showAction() code :

/**
 * 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

2 Answers

1
votes

Try to follow below steps to call flexform.

in your ext_tables.php file add below code.

//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'
);

Now, create flexform file in this directory /Configuration/FlexForms/ like below and use userFunct for event select list.

<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>

Now, Create tx_event_utility.php file on this path /ext_key/Classes/Utility/ like below.

<?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;
    }

}
?>
0
votes

Add file 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'
);