What is the alternative of switchable controller in typo3 - typo3

What if two different methods of an extension need to be called in two different places?
Example:
What if I want to use the method of one controller of the same extension on the home page and the method of another controller on another page?

Create two different plugins.
Example: Instead of flexform
<switchableControllerActions>
<TCEforms>
<label>switchable controller actions</label>
<config>
<renderType>selectSingle</renderType>
<items>
<numIndex index="1">
<numIndex index="0">List</numIndex>
<numIndex index="1">Product->list</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">Show</numIndex>
<numIndex index="1">Product->show</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
Create two plugins.
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'extension',
'list',
[
'Product' => 'list'
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'extension',
'show',
[
'Product' => 'show'
]
);
More details see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.3/Deprecation-89463-SwitchableControllerActions.html

Related

Typo3 8.7.10 Switchable Controller Actions not working

From researching examples I have tried to create a switchable control action for my extension plugin, but it is not showing up. Can anybody help me figure out why?
In my ext_localconf.php I have the following:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'myeventplugin',
'Pi1',
[
'Events' => 'list, display'
],
// non-cacheable actions
[
'Events' => 'list, display'
]
);
In my ext_tables.php I have the following:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'myeventplugin',
'Pi1',
'Events'
);
$pluginSignature = 'myeventplugin_Pi1';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:myeventplugin/Configuration/FlexForms/flexform_pi1.xml');
In my Configuration/FlexForms/flexform_pi1.xml I have the following:
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Events Plugin Config</sheetTitle>
</TCEforms>
<type>
array
</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>View</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Event List</numIndex>
<numIndex index="1">Events->list</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Event Display</numIndex>
<numIndex index="1">Events->display</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
When I include the plugin I don't see the additional select menu that I have created, therefore I can't specify which action I want it to call.
I thought that perhaps the $pluginSignature variable was incorrect due to the casing. Therefore in ext_tables.php in have tried the following:
$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY));
$pluginSignature = $extensionName.'_'.'Pi1';
and
$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY));
$pluginSignature = $extensionName.'_'.'pi1';
and
$pluginSignature = 'myeventplugin_Pi1';
and
$pluginSignature = 'myeventplugin_pi1';
...but still no luck
I have a look in my last extension: in ext_tables.php i wrote
$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extKey));
$pluginName = strtolower('plg');
$pluginSignature = $extensionName.'_'.$pluginName;
so, im my case $pluginSignature = 'thoffer_plg', in your case it has to be 'myeventplugin_pi1'.
Next lines:
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:'.$extKey . '/Configuration/FlexForms/contentPlugin.xml');
This is functional for me, in your case it looks ok. The best way is to reinstall the extension, if you change values for flexforms, because this is normally deeply cached.

TYPO3 FlexForm is not appearing

This is my code. I don't know where is the mistake? Please refere following code and help me
$pluginSignature = str_replace('_','',$_EXTKEY) . '_rock';
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( 'Rocktechnolabs.' . $_EXTKEY, 'rock', 'THE FAQS' );
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_rock.xml');
in Configuration/FlexForms/flexform_rock.xml
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Function</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Select function</label>
<config>
<type>select</type>
<items>
<numIndex index="0">
<numIndex index="0">List</numIndex>
<numIndex index="1">Faq->list</numIndex>
</numIndex>
<numIndex index="1">
<numIndex index="0">Search</numIndex>
<numIndex index="1">Faq->search</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
I tried a lot but i am not getting flexform during select plugin. Can you help me to find out the mistake?
You must add the flexform field to the subtypes_addlist:
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
make sure your $pluginSignature matches result of $pluginSignature within ExtensionUtility::registerPlugin().
This is what's happening in that method:
$extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', $extensionName)));
$pluginSignature = strtolower($extensionName) . '_' . strtolower($pluginName);
To me this looks different :)
Adding $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; as Rene suggested is important as well.

How to translate templavoila template code to Fluid/Flux templating

I have a question regarding templavoila and Fluid.
I migrated my website from TYPO3 4.7.x to TYPO3 6.2.x where the TYPO3 4.7.x uses Templavoila.
I now want to translate Templavoila code to Fluid/Flux code.
for example I have a TemplaVoila Flexible CE for dropdown:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta type="array">
<langDisable>1</langDisable>
</meta>
<ROOT type="array">
<tx_templavoila type="array">
<title>ROOT</title>
<description>description</description>
</tx_templavoila>
<type>array</type>
<el type="array">
<field_dropdown_toggle type="array">
<tx_templavoila type="array">
<title>Text Dropdown Toggle</title>
<sample_data type="array">
<numIndex index="0">Style</numIndex>
</sample_data>
<eType>input</eType>
<proc type="array">
<HSC type="integer">1</HSC>
</proc>
<TypoScript type="NULL"></TypoScript>
</tx_templavoila>
<TCEforms type="array">
<config type="array">
<type>input</type>
<size>200</size>
<eval>trim</eval>
</config>
<label>Text Dropdown Toggle</label>
</TCEforms>
</field_dropdown_toggle>
<field_dropdown_menu type="array">
<tx_templavoila type="array">
<title>Dropdown-Menü</title>
<sample_data type="array">
<numIndex index="0"></numIndex>
</sample_data>
<eType>ce</eType>
<TypoScript>
10 = RECORDS
10.source.current = 1
10.tables = tt_content
</TypoScript>
<oldStyleColumnNumber type="integer">0</oldStyleColumnNumber>
</tx_templavoila>
<TCEforms type="array">
<config type="array">
<type>group</type>
<internal_type>db</internal_type>
<allowed>tt_content</allowed>
<size>5</size>
<maxitems>200</maxitems>
<minitems>0</minitems>
<multiple>1</multiple>
<show_thumbs>1</show_thumbs>
</config>
<label>Dropdown-Menü</label>
</TCEforms>
</field_dropdown_menu>
<field_dropdown_header type="array">
<tx_templavoila type="array">
<title>Überschrift</title>
<sample_data type="array">
<numIndex index="0"></numIndex>
</sample_data>
<eType>none</eType>
<TypoScript>
10 = TEXT
10.data = register:tx_templavoila_pi1.parentRec.header
</TypoScript>
<preview></preview>
</tx_templavoila>
</field_dropdown_header>
<field_dropdown_header_layout type="array">
<type>attr</type>
<tx_templavoila type="array">
<title>Header Typ</title>
<eType>none</eType>
<TypoScript>
10 = TEXT
10 {
data = register:tx_templavoila_pi1.parentRec.header_layout
wrap = dropdown-header h|
}
</TypoScript>
<proc type="array">
<HSC type="integer">1</HSC>
</proc>
</tx_templavoila>
</field_dropdown_header_layout>
</el>
</ROOT>
</T3DataStructure>
and I would like to transform this code to flux like this:
<flux:field.input name="textToggle" label="Text Dropdown Toggle" />
Is there a documentation how to transform?
here is the screenshot of templavoila
How do I get exactly like using flux/fluid. I can get Input field but cannot get dropdown-menu.
Can anyone please suggest me what to do.
If my question is not clear, please let me know and I will try to explaiin it again.
I would appreciate your Help.
The extension sf_tv2fluidge (I'm the author) only supports migration of TV flexible content elements to GridElements. Since you are using flux, the migration will not work with sf_tv2fluidge.
You could try to use the fork of sf_tv2fluidge from techniConcept. They support flux, but require fluidpages and fluidcontent.

Same Model, different Templates (and Actions) in extbase extension

I don't know if I've set up my extension a little quirky.
I have one model, but two plugins, as I would like to display the same data in different ways.
What thought I'd do: assign pi1 and pi2 two different Fluid templates, where all the display logic is done. But as far as I understood now, there is no such switch, due to "Convention over configuration", I need a separate controller for pi2, right?
Now I have this in ext_tables.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'STUBR.' . $_EXTKEY,
'Pi1',
array(
'Institution' => 'list, show',
),
// non-cacheable actions
array(
'Institution' => '',
)
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'STUBR.' . $_EXTKEY,
'Pi2',
array(
'Institution' => 'list, show',
),
// non-cacheable actions
array(
'Institution' => '',
)
);
Do I really have to adapt everything by re-naming "Institution" here, in the Controller(s) and in the template directories?
To answer the question you asked in your answer ... it is possible to configure the TypoScript of your Extension on a per plugin base. Just add the pluginname with a leading underscore to your TS key like this
plugin.tx_stellen_pi2 {
settings {
displaymode = 1
}
}
Instead of using a if condition you could also set a different TemplateRootPath so another template would be rendered for pi2.
Remember that you can set the displayMode in a FlexForm. Every FlexForm property prefixed with settings. will be available in the {settings} array. Just configure the FlexForm in ext_tables.php:
$pluginSignature = str_replace('_','',$_EXTKEY) . '_pi1';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForm/flexform_pi1.xml');
Then add the FlexForm XML to the path configured:
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Configuration</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.displayMode>
<TCEforms>
<exclude>0</exclude>
<label>Display mode</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Neat</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Clean</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
</items>
<minitems>0</minitems>
<maxitems>1</maxitems>
<size>1</size>
</config>
</TCEforms>
</settings.displayMode>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
In this example, a select box with two options "neat" and "clean" is added.
You can then use this in your Fluid template (you could also use the SwitchViewHelper instead of the if construct if you have more than two modes):
<f:if condition="{settings.displayMode} == 1">
<f:then>
<f:render partial="Neat/List" arguments="{_all}" />
</f:then>
<f:else>
<f:render partial="Clean/List" arguments="{_all}" />
</f:else
</f:if>
Remember that you can nest partials, so it's no problem to have a partial in a partial in a partial. So just use a partial for each view.
If you want to have it less hackish-looking, you could give the display mode a speaking value:
<numIndex index="0" type="array">
<numIndex index="0">Neat</numIndex>
<numIndex index="1">Neat</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Clean</numIndex>
<numIndex index="1">Clean</numIndex>
</numIndex>
Then you can use this to call the partial like this
<f:render partial="List/{settings.displayMode}" arguments="{_all}" />
and get rid of the if construct that way.
I'm doing it this way now. Keep one controller, just fork the template by setting some page TS on the page the plugin is on.
plugin.tx_stellen {
settings {
displaymode = 1
}
}
and then <f:if condition="{settings.displaymode}==1"></f:if>
This is workaroundish, though, as it is valid for the entire page (and I wouldn't even need the three different plugins at all). Isn't it possible to define TypoScript "per Plugin" directly in the extension?

TYPO3 - How to show the right language only in FlexForm

In Flexform I have a tree view where I can select categories for my product. But it shows all three languages. It should only show the language that is the same as the element language.
What did I miss?
<T3DataStructure>
<meta type="array">
<langChildren type="integer">0</langChildren>
<langDisable type="integer">1</langDisable>
</meta>
<sheets>
<main>
<ROOT>
<TCEforms>
<sheetTitle>Options</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.flexform.showCategory>
<TCEforms>
<exclude>1</exclude>
<label>Vælg kategori 1:</label>
<config>
<type>select</type>
<renderMode>tree</renderMode>
<treeConfig>
<parentField>maincategory</parentField>
<appearance>
<expandAll>FALSE</expandAll>
<showHeader>TRUE</showHeader>
</appearance>
</treeConfig>
<size>10</size>
<minitems>0</minitems>
<maxitems>999</maxitems>
<autoSizeMax>5</autoSizeMax>
<multiple>0</multiple>
<foreign_table>tx_origproducts_domain_model_category</foreign_table>
<!-- ###STORAGE_PID### is set by the field GENERAL STORAGE PAGE on the page record - or a parent page record to affect a hole branch -->
<foreign_table_where></foreign_table_where>
<size>10</size>
<items type="array">
<numIndex index="100">
<numIndex index="0">Alle</numIndex>
<numIndex index="1">-1</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</settings.flexform.showCategory>
</el>
</ROOT>
</main>s
</sheets>
Here is a snippet that only shows the foreign entries of the same language.
<foreign_table_where>AND (sys_language_uid=CAST('###REC_FIELD_sys_language_uid###' AS UNSIGNED) OR sys_language_uid = '-1') AND tx_origproducts_domain_model_category.deleted = 0 AND tx_origproducts_domain_model_category.hidden = 0</foreign_table_where>