Pavenstaedter
Pavenstaedter

Reputation: 67

typo3 plugin: how to pass a parameter?

I've got a plugin in typo3 where I do a database query with a limit of 5 for example. I now looking for a solution to choose this limit in the backend of typo3 (select box,radio buttons,...) and to pass it as a parameter - do you have any idea?

Thanks Volker

Upvotes: 0

Views: 617

Answers (1)

Georg Ringer
Georg Ringer

Reputation: 7939

I guess you are using an extension based on extbase! The configuration is called Flexforms and can be implemented very easily

As an example, take a look at one of my extensions:

Configuration/TCA/Overrides/tt_content.php Place such code

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['mailchimp_registration'] = 'recursive,select_key,pages';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['mailchimp_registration'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('mailchimp_registration',
    'FILE:EXT:mailchimp/Configuration/FlexForms/flexform_mailchimp.xml');

of course you need to adopt it to your needs

flexform_mailchimp.xml

Add the flexform file which holds the configuration:

<T3DataStructure>
    <meta>
        <langDisable>1</langDisable>
    </meta>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>LLL:EXT:mailchimp/Resources/Private/Language/locallang.xml:flexform.title</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <settings.fo>
                        <TCEforms>
                            <label>LLL:EXT:mailchimp/Resources/Private/Language/locallang.xml:flexform.useAjax</label>
                            <config>
                                <type>input</type>
                                <default>0</default>
                            </config>
                        </TCEforms>
                    </settings.fo>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

As the setting is named settings.fo, you can then get the value in the controller by using $this->settings['fo'].

Upvotes: 6

Related Questions