How to Create Frontend Plugin in TYPO3?

Category : Extbase , By : Sanjay Chauhan

Let's create frontend plugin in your custom TYPO3 extension, Just register frontend plugin and override tt_content.php and setup TYPO3 FlexForm.

Step 1. Overrides tt_content.php

# Create /Configuration/TCA/Overrides/tt_content.php

<?php
if (!defined('TYPO3_MODE')) { die('Access denied.'); }

call_user_func(function () {

	# Define extension key
	$_EXTKEY = 'extension_key';

	# Should move code from ext_tables.php to here > To register plugin
	\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
	    $_EXTKEY,
	    'Pi1',
	    'Title'
	);

	# Prepare plugin's signature
	$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY));
	$pluginName = strtolower('Pi1');
	$pluginSignature = $extensionName.'_'.$pluginName;

	# Add list_type to tt_content
	$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';

	# Add Flexform
	\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
		$pluginSignature,
		'FILE:EXT:'.$_EXTKEY . '/Configuration/FlexForms/pi1_name.xml'
	);
});

Step 3. Create TYPO3 FlexForm

<!-- /Configuration/FlexForms/pi1_name.xml -->

<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Fields</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <headline>
                        <TCEforms>
                            <label>Headline</label>
                            <config>
                                <type>input</type>
                                <eval>required</eval>
                            </config>
                        </TCEforms>
                    </headline>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

To keep improving, Do you have feedback and suggestions? Or, Are you facing any issues to implement above TYPO3 tutorial? Feel free to write your comment at below comment box; I'll happy to help you :)

Post Comment

Your email address will not be published. Required fields are marked *

×

Name is required!

Enter valid name

Valid email is required!

Enter valid email address

Comment is required!

Google Captcha Is Required!

Be the First to Comment

Stay up to date with our recent TYPO3 Blogs, news, & updates