It would be very convenient in the case of end-user controlled layout options. E.g:
<div class="ImageContainer <<PositionClass>>">
<img src="/someimage.png" />
</div>
The position class (like maybe Left, Right, Background) would be set the user by selecting a layout option from a drop down in content element. The problem is, that if you map such an option to the class attribute of the container div, the base class(named ImageContainer in the above example) will be overwritten.
Is it possible to append a value to an existing attribute rather that overwriting it completely?
I've seen work-around where the end-user controlled layout option is mapped to the name attribute in stead, but i find this inelegant.
Create your composed class names in TypoScript. This way you are able to compile them from fixed and variable parts and you can even take multiple FCE fields into account.
Here is an example:
DS XML
<field_imagepos type="array">
<type>no_map</type>
<tx_templavoila type="array">
<title>Image Positioning</title>
<sample_data type="array">
<numIndex index="0"></numIndex>
</sample_data>
<eType>select</eType>
</tx_templavoila>
<TCEforms type="array">
<config type="array">
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">Left</numIndex>
<numIndex index="1">Left</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Right</numIndex>
<numIndex index="1">Right</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">Background</numIndex>
<numIndex index="1">Background</numIndex>
</numIndex>
</items>
<default>Left</default>
</config>
<label>Image Positioning</label>
</TCEforms>
</field_imagepos>
<field_calc_class type="array">
<type>attr</type>
<tx_templavoila type="array">
<title>(Calculating the class attribute)</title>
<description>Pick ATTR class='ImageContainer ...'</description>
<sample_data type="array">
<numIndex index="0"></numIndex>
</sample_data>
<eType>TypoScriptObject</eType>
<tags>div:attr:class</tags>
<TypoScriptObjPath>lib.calcClass</TypoScriptObjPath>
</tx_templavoila>
</field_calc_class>
TypoScript
lib.calcClass = TEXT
lib.calcClass{
dataWrap = ImageContainer {field:field_imagepos}
}
I know this one's a bit old, but at the moment I'm trying to do something similar and I guess you could add an extra html element to wrap the image element, like this:
HTML:
<div class="ImageContainer">
<div class="<<positionClass>>">
<img src="/someimage.png" />
</div>
</div>
Of course you would have to adjust your CSS to fit your needs.
Or else, you could add the "ImageContainer" class to the select values, like this:
DS XML:
[...]
<items type="array">
<numIndex index="0" type="array"
<numIndex index="0">Left</numIndex>
<numIndex index="1">ImageContainer Left</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">Right</numIndex>
<numIndex index="1">ImageContainer Right</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">Background</numIndex>
<numIndex index="1">ImageContainer Background</numIndex>
</numIndex>
</items>
[...]
HTH, best regards,
Michael
Related
With TCEFORM in Page TS, you can remove a FlexForm field from an extension plugin, e.g. from EXT:news:
TCEFORM.tt_content.pi_flexform.news_pi1.additional.settings\.detailPid.disabled = 1
The example above is working, but how can I remove a field from a gridelements FlexForm?
This is not working:
TCEFORM.tt_content.pi_flexform.gridelements_pi1.mySheet.myField.disabled = 1
More detailled:
I use EXT:bootstrap_grids, which provides FlexForm "flexform_2col.xml". From this FlexForm, I want to disable tab "largeDevices" with fields "lgCol1" and "lgCol2":
<T3DataStructure>
<sheets>
[...]
<largeDevices>
<ROOT type="array">
<TCEforms>
<sheetTitle>LLL:EXT:bootstrap_grids/Resources/Private/Language/locallang_db.xlf:grid.sheet.largeDevices</sheetTitle>
</TCEforms>
<type>array</type>
<el type="array">
<lgCol1 type="array">
<TCEforms type="array">
<label>LLL:EXT:bootstrap_grids/Resources/Private/Language/locallang_db.xlf:grid.label.col1</label>
<config type="array">
<type>select</type>
<renderType>selectSingle</renderType>
<itemsProcFunc>Laxap\BootstrapGrids\Controller\FlexFormController->getTwoColumnOptions</itemsProcFunc>
</config>
</TCEforms>
</lgCol1>
<lgCol2 type="array">
<TCEforms type="array">
<label>LLL:EXT:bootstrap_grids/Resources/Private/Language/locallang_db.xlf:grid.label.col2</label>
<config type="array">
<type>select</type>
<renderType>selectSingle</renderType>
<itemsProcFunc>Laxap\BootstrapGrids\Controller\FlexFormController->getTwoColumnOptions</itemsProcFunc>
</config>
</TCEforms>
</lgCol2>
</el>
</ROOT>
</largeDevices>
But it seems, EXT:gridelements handles the FlexForm in some other way so it can't be manipulated with TCEFORM, this is not working:
TCEFORM.tt_content.pi_flexform.gridelements_pi1.largeDevices.lgCol1.disabled = 1
The key "gridelements_pi1" is wrong. It can be either "default", effecting all gridelement layout types or a specific type you defined.
So this would work for the excample from the question:
TCEFORM.tt_content.pi_flexform.default.largeDevices.lgCol1.disabled = 1
I'm building an extension and I have a field of type flex. I have an array with extracted records from a TS config that I like to use as prefilled values for a field, which I also want to be editable in the TYPO3 admin. So I want them to be shown as textarea, however I don't know how to use the array in the flex items configuration.
'<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Title</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pageSelector>
<TCEforms>
<label>Something</label>
<config>
<type>text</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">'.$php_variable_array.'</numIndex>
<numIndex index="1">0</numIndex>
</numIndex>
</items>
<minitems>0</minitems>
<maxitems>1</maxitems>
</config>
</TCEforms>
</pageSelector>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>'
I need to create a flexform field where the user is able to select a tt_content element - but I want to limit that to only tt_content elements from a certain page. What I have so far:
<settings.test>
<TCEforms>
<label>test</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>tt_content</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<show_thumbs>1</show_thumbs>
</config>
</TCEforms>
</settings.test>
is there a way to limit it to a specific page? The typo3 Version is 7.6.10.
Thank you in advance.
The <type>group</type> is used for a browselike behavior and i can not see how you can add a filter there. Since you want to show a limited number of elements, you can use <type>select</type> with foreign_table_where
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<foreign_table>tt_content</foreign_table>
<foreign_table_where>AND tt_content.pid = ###PAGE_TSCONFIG_ID###</foreign_table_where>
<size>1</size>
<items>
<numindex index="0">
<numindex index="0">--</numindex>
<numindex index="1"></numindex>
</numindex>
</items>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
Then you need to set the id in your Page Config
TCEFORM.tt_content.pi_flexform.PAGE_TSCONFIG_ID = 123
I using the Typo3 7.6.10 Extbase Builder.
I have a created an extension and a have a model with one controller.
In my controller i have 2 actions. list(); searchbar();
Now i want to choose in the backend when im adding the plugin which action to start! I can't manage to do this option.
I heard about the FlexForm Options and switchableControllerActions.
But i can't manage to do this. The Documentation is bad https://wiki.typo3.org/Extension_Development,_using_Flexforms#Create_Your_Extension
For Example: t3lib_extMgm is deprecated
Is there a valid example how to do this?
Create an .xml file. I know of no convention, but it's a good idea to name the file the same as your plugin, because you need separate files for each plugin type of your extension.
typo3conf/ext/extensionkey/Configuration/FlexForms/Pluginname.xml
The xml file needs to contain at least a TCEform structure with the key switchableControllerActions as a select type option, like so.
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<sheetTitle>Display type</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>Display</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="1" type="array">
<numIndex index="0">List</numIndex>
<numIndex index="1">Controller->list</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">Search bar</numIndex>
<numIndex index="1">Controller->searchbar</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>
Next, make the Flexform known in the Backend by registering the file. Make note of the $pluginSignature variable. It must match the pattern of extension_pluginname. You'll have to define the plugin name accordingly.
// Register FlexForm Configuration
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['extension_plugin'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
'extension_plugin',
'FILE:EXT:extensionkey/Configuration/FlexForms/Pluginname.xml'
);
In the example above, replace "extension_plugin" and "extensionkey" accordingly.
Lastly, flush the system cache and you should be good to go. The configuration option should turn up in the plugins settings. The switchableControllerActions value defined should then replace your standard action for the plugin instance.
There are, however, a few more things to point out: Note, that the actions you define replaces the allowed cacheableControllerAction combination. So, if your extension has, for extample, another action show() for this plugin instance, that one needs to be appended like so:
<numIndex index="1" type="array">
<numIndex index="0">List</numIndex>
<numIndex index="1">Controller->list;Controller->show</numIndex>
</numIndex>
I have the own extension that has controller with two actions: listAction and showAction.
Question: Can I display two actions at the same page.
At specific page I've created an insert plugin record with my own plugin where in flexform of backend configuration of the plugin I've choosen "list action" via switchableControllerActions field. The list action contains list of products with link to the show action of product.
So what do I want?
F.e.
I have page Products. The URL is example.com/products (here is my list action)
And for show action I want the URL like example.com/products/name-of-product
I've found a extension with this functionality. It's gb_events. And I noticed that in switchableControllerActions field of flexform of plugin there is something like this:
<switchableControllerActions>
<TCEforms>
<label>LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.upcoming</numIndex>
<numIndex index="1">Event->upcoming;Event->list;Event->calendar;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.list</numIndex>
<numIndex index="1">Event->list;Event->upcoming;Event->calendar;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.calendar</numIndex>
<numIndex index="1">Event->calendar;Event->upcoming;Event->list;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.details</numIndex>
<numIndex index="1">Event->show;Event->list;Event->upcoming;Event->calendar;Event->export</numIndex>
</numIndex>
</items>
<maxitems>1</maxitems>
<size>1</size>
</config>
<onChange>reload</onChange>
</TCEforms>
</switchableControllerActions>
I've updated my flexform configuration. But it still doesn't work. I've the same list view after when I click on link with show action.
Thanks in advance. I will appreciate any help.
The structurally more sensical approach is to keep that sort of logic inside the controller.
Make your showAction the defaut one and check the arguments in its initializaion. If no product was given, or the specified one cannot be loaded, forward to the list action.
/**
* initialize action show
* #return void
*/
public function initializeShowAction() {
if($this->request->hasArgument('product')){
if( $product=$this->stadtRepository->findByUid(
intval($this->request->getArgument('product'))
) ){
$this->request->setArgument('product',$product);
return;
}
}
$this->forward('list');
}
Make sure you have both, the list and detail Action in your switchableControllerActions like so:
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.upcoming</numIndex>
<numIndex index="1">Event->list;Event->calendar;Event->show</numIndex>
</numIndex>
Then in your TypoScript Template use a condition to set the Controller / Action based on a detail uid:
[globalVar = GP:tx_myext_plugin|showUid > 0]
config.defaultGetVars {
tx_myext_plugin.action = show
}
[global]
To get the other controller parameter off the URL in RealUrl use something like this:
array(
'GETvar' => 'tx_extkey_plugin[action]',
'noMatch' => 'bypass'
),
You can find more about this trick in this german article here