TYPO3 - Custom extension : show in flexform - typo3

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

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

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

Related

TYPO3 backend Icon with iconidentifier for custom content element

I registered my icons in ext_localconf.php like this:
<?php
use TYPO3\CMS\Core\Imaging\IconRegistry;
$extKey = 'xxx';
if (TYPO3_MODE === 'BE') {
/** #var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerIcon(
'xxx_intro-icon-identifier',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
['source' => 'EXT:' . $extKey . '/Resources/Public/icons/baseline-web_asset-24px.svg']
);
I want to use the iconidentifier in tt_content.php with \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin() to set the icon for the drop-down menu. Who do I achieve this?
I know this solution:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'LLL:EXT:your_extension/Resources/Private/Language/locallang_db.xlf:your_ctype.title',
'your_ctype',
'your_icon_identifier'
],
'textmedia',
'after'
);
Place this snippet in Configuration/TCA/Overrides/tt_content.php

TYPO3 - TCA in ext_tables.php check and TCA/Overrides for v8

Updated ext_tables.php, TCA and TCA/Overrides for TYPO3 8LTS? I moved the TCA definitions from ext_tables.php to /TCA folder and the query in list view is working again:
ext_tables.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Code',
'Description'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_code_domain_model_code', 'EXT:code/Resources/Private/Language/locallang_csh_tx_code_domain_model_code.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_code_domain_model_code');
Configuration/TCA/tx_code_domain_model_code.php
... // TCA defintions
Configuration/TCA/Overrides/tt_content.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
$_EXTKEY = 'code';
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Code',
'Description'
);
$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY));
$pluginName = strtolower('Code');
$pluginSignature = $extensionName.'_'.$pluginName;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:'.$_EXTKEY . '/Configuration/FlexForms/flexform_code.xml');
Configuration/TCA/Overrides/tt_content.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('code', 'Configuration/TypoScript', 'Description');
It's not compatible.
You should do your TCA definition of tx_code_domain_model_code in:
Configuration/TCA/tx_code_domain_model_code.php
The static template definition in:
Configuration/TCA/Overrides/sys_template.php
And your plugin and flexform definition in: Configuration/TCA/Overrides/tt_content.php
Be aware that the $_EXTKEY variable is not defined in those files so you have to type the extension key yourself.

The default controller for extension and plugin can not be determined

Good afternoon, dear friends! All, I give up. Tried well, all that was already possible. TYPO3 7.6.16
ext_tables.php:
<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'MyVendor.' . $_EXTKEY,
    'Pi1',
    'The inventory list'
);
ext_localconf.php:
<?php
if (!defined('TYPO3_MODE')) die ('Access denied.');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.' . $_EXTKEY,
    'Pi1',
    Array ('Comment' => 'list'),
    Array ('Comment' => 'list')
);
And constantly the same mistake
The default controller for extension "Fecomments" and plugin "Pi1" can not be determined
I read topics with same error but nothing help me.
I already climbed into the kernel, found out that $configuration ['controllerConfiguration'] is an empty array, I do not know why data does not arrive there. Comrades, help me out, I do not know what to do, honestly! )
At first, use the correct syntax for the two files. Examples:
ext_tables.php:
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function($extKey)
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'VENDOR.Extensionkey',
'Pi1',
'Extension Display Name'
);
},
$_EXTKEY
);
ext_localconf.php:
<?php
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function($extKey)
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'VENDOR.' . $extKey,
'Pi1',
[
'First' => 'action1, action2'
],
// non-cacheable actions
[
'First' => ''
]
);
},
$_EXTKEY
);
The make sure the namespace and class name are fine:
typo3conf/ext/extensionkey/Classes/Controller/FirstController.php:
/***
*
* This file is part of the "extensionkey" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2017
*
***/
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* FilecollectorController
*/
class FirstController extends ActionController
{
/**
* action1
*
* #return void
*/
public function action1Action()
{
}
/**
* action1
*
* #return void
*/
public function action2Action()
{
}
}
Clear all caches. Sometimes it will help to go into ExtensionManager and disable/enable the whole extension. In case of changed classnames or changes in the tables/localconf files, this will flush ALL caches.
The solution provided by Mikael is not available at the moment.
Short version of the external website, that is currently offline:
Try to delete and recreate the content element on your page to delete old flexform values

Typo3 backend module form error

I have no idea why, but the error just disappear without any changes. Now it works. I have not change anything. (I deleted cache many times so it cannot be because of the cache)
Problem
I created an extension using extension builder (if anyone knows any good documentation please give me link because official documentation does not have any examples).
I have a form and when I submit the form I have the error
TYPO3 v4.7
The action "formSave" (controller "Promoters") is not allowed by this plugin. Please check Tx_Extbase_Utility_Extension::configurePlugin() in your ext_localconf.php.
I created ext_localconf.php according to typo's wiki.
Form code
<f:form action="formSave" name="" object="">
<f:form.textfield id="emailResendInterval" name="emailResendInterval" value="" />
<f:form.textarea cols="30" rows="5" id="emails" name="emails" value="" />
<f:form.submit name="submit" value="Save" />
</f:form>
ext_localconf.php
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY] = unserialize($_EXTCONF);
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['registerSinglePlugin']) {
// fully fletged blog
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY, // The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
'Promoters', // A unique name of the plugin in UpperCamelCase
array ( // An array holding the controller-action-combinations that are accessible
'Promoters' => 'configuration,formSave', // The first controller and its first action will be the default
),
array( // An array of non-cachable controller-action-combinations (they must already be enabled)
)
);
} else {
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY, // The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
'Promoters', // A unique name of the plugin in UpperCamelCase
array ( // An array holding the controller-action-combinations that are accessible
'Promoters' => 'configuration,formSave', // The first controller and its first action will be the default
),
array( // An array of non-cachable controller-action-combinations (they must already be enabled)
)
);
PromotersControler
class Tx_Promoters_Controller_PromotersController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* action configuration
*
* #return void
*/
public function configurationAction() {
}
/**
* action formSave
*
* #return void
*/
public function formSaveAction() {
}
}
Seems fine actually, I'm not sure about the if statemant in the localconf though. Please try this:
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
// fully fletged blog
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY,
'Promoters',
array (
'Promoters' => 'configuration,formSave',
),
array(
)
);
?>

Editable Breadcrumb for Dynamic Pages

Looking for a better Breadcrumb solution for a Zend Framework project.
Currently I have a navigation.xml like
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<module>default</module>
<controller>index</controller>
<action>index</action>
<pages>
<countryurl>
<label>Spain</label>
<module>default</module>
<controller>country</controller>
<action>index</action>
<route>country_url</route>
<params>
<country>spain</country>
</params>
<pages>
<provinceurl>
<label>Madrid</label>
<module>default</module>
<controller>country</controller>
<action>province</action>
<route>province_url</route>
<params>
<country>spain</country>
<province>madrid</province>
</params>
<pages>
<cityurl>
<label>City</label>
<module>default</module>
<controller>country</controller>
<action>city</action>
<route>city_url</route>
<params>
<country>spain</country>
<province>madrid</province>
<city>madrid</city>
</params>
<pages>
<producturl>
<label>Product</label>
<module>default</module>
<controller>country</controller>
<action>product</action>
<route>product_url</route>
<params>
<country>spain</country>
<province>madrid</province>
<city>madrid</city>
<product>product</product>
</params>
</producturl>
</pages>
</cityurl>
</pages>
</provinceurl>
</pages>
</countryurl>
</pages>
</home>
</nav>
</configdata>
and routes like
$router->addRoute(
'product_url',
new Zend_Controller_Router_Route(':lang/:country/:province/:city/:product', array(
'controller' => 'country',
'action' => 'product'
))
);
$router->addRoute(
'city_url',
new Zend_Controller_Router_Route(':lang/:country/:province/:city', array(
'controller' => 'country',
'action' => 'city'
))
);
$router->addRoute(
'province_url',
new Zend_Controller_Router_Route(':lang/:country/:province', array(
'controller' => 'country',
'action' => 'province'
))
);
$router->addRoute(
'country_url',
new Zend_Controller_Router_Route(':lang/:country', array(
'controller' => 'country',
'action' => 'index'
))
);
I am facing some issues / looking for some suggestions . Creating the Breadcrumbs with the help of Zend_Navigation
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
$view->navigation($container);
1 ) The request for http://example.com/en/spain/madrid/madrid/product shows the breadcrumb, with the help of
$this->navigation()
->breadcrumbs()
->setMinDepth(0)
->setLinkLast(true)
->setSeparator(" > ");
as Home > Spain > Madrid > City > Product
But the links pointing at Spain , Madrid , City all are to http://example.com . Which should be http://example.com/en/spain , http://example.com/en/spain/madrid , http://example.com/en/spain/madrid/madrid respectively.
2 ) Currently when the request for http://example.com/en/spain
the breadcrumb will show Home >> Spain
<label>Spain</label>
<module>default</module>
<controller>country</controller>
<action>index</action>
<route>country_url</route>
<params>
<country>spain</country>
</params>
But you can see the param country differs according to country. So do we want to add the labels for all countries ?
http://example.com/en/spain
Home >> Spain
http://example.com/en/india
Home >> India
I have provinces , city and product coming along, any suggestions how I can build for it ?
Also this is a multilingual website, so how can we make the necessary changes to the label? I guess if we are using Zend_Translate it will make the necessary changes.
You can create your own page class that treats params beginning with : as dynamic. You can reference it in the nav configuration like
...
<countryurl>
<label>:country</label> <!-- dynamic -->
<module>default</module>
<controller>index</controller>
<action>index</action>
<route>country_url</route>
<type>DynamicNavPage</type> <!-- page classname -->
<params>
<country>:country</country> <!-- dynamic -->
</params>
<pages>
...
and for example
<?php
class DynamicNavPage extends Zend_Navigation_Page_Mvc {
/**
* Params with ":" are read from request
*
* #param array $params
* #return Zend_Navigation_Page_Mvc
*/
public function setParams(array $params = null) {
$requestParams = Zend_Controller_Front::getInstance()
->getRequest()->getParams();
//searching for dynamic params (begining with :)
foreach ($params as $paramKey => $param) {
if (substr($param, 0, 1) == ':' &&
array_key_exists(substr($param, 1), $requestParams)) {
$params[$paramKey] = $requestParams[substr($param, 1)];
}
}
return parent::setParams($params);
}
/**
* If label begining with : manipulate (for example with Zend_Tanslate)
*/
public function setLabel($label) {
if (substr($label, 0, 1) == ':') {
//label modifications go here
//as an example reading it from page params and capitalizing
//can use Zend_Translate here
$requestParams = Zend_Controller_Front::getInstance()
->getRequest()->getParams();
$labelParamKey = substr($label, 1);
if (array_key_exists($labelParamKey, $requestParams)) {
$label = ucfirst($requestParams[$labelParamKey]);
}
}
return parent::setLabel($label);
}
}