TYPO3: Appearance > Layout is missing in Gridelements - typo3

For a project I'm using TYPO3 7.6.11 with fluid_styled_content and Gridelements 7.0.5.
Unfortunately the field "Layout" in "Appearance" is missing in grid elements. For every other content element the layout field is available.
I can exclude problems with other extensions. I did not override the TCA by myself and there's no problem with my page ts configuration.
What's the problem here?
I'm pleased about every hint. Thanks!

In this case you got two options, since the Gridelements TCE form is based on a TCA palette named "frames", which has been removed with Fluid Styled Content.
So you will either have to add the missing fields directly to the showitem section of
tt_content => types => gridelements_pi1
just as they are used in Fluid Styled Content. Or you can add the missing palette "frames" by taking the definition from CSS Styled Content and adding it to the TCA palettes of tt_content.
Both should be done in your own extension within
Configuration => TCA => Overrides => tt_content.php
And finally there is another option: Wait for the next releases of Gridelements, since they will take care of the problem automagically ;-)

Thanks again to Joey for giving the correct hint. I now extended the TCA with the following lines of code:
$GLOBALS['TCA']['tt_content']['palettes'] = array_replace(
$GLOBALS['TCA']['tt_content']['palettes'],
[
'frames' => [
'showitem' => '
layout;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:layout_formlabel,
spaceBefore;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:spaceBefore_formlabel,
spaceAfter;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:spaceAfter_formlabel,
section_frame;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:section_frame_formlabel
',
]
]
);

Related

CType not showing up in dropdown, TYPO3 version 11.5.23

I try to create my extension. The extension is called personal. So I use the personal_ prefix for the CType.
TYPO3 has version 11.5.23
For the dropdown, I think the only thing I have to do is to create the tt_content.php
I tried this guide:
https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html
Configuration/TCA/Overrides/tt_content.php
// Add the content element to the "Type" dropdown
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'Titel',
'personal_titel',
'content-text',
],
'textmedia',
'after'
);
But when I choose it from the wizard, the CType is unknown.
Had that behaviour once i had limited the allowed CEs of the content column (maybe you use grielements or sth elese).
I had to explicitly allow my CE in the content column config and after clearing the cache it worked. Maybe it helps in your case, too?

TYPO3 selectMultipleSideBySide translate "Available Items" per record type

I want to override the label strings "Available Items" and "Selected Items" in a selectMultipleSideBySide form because it is too generic. I have multiple record types using this form template so I cannot change the strings globally.
I tried to change it in the TCA of my custom record type without success. I only see the label for the entire relation.
I am using TYPO3 8.7
Does anyone know an extension which accomplished this or does anyone know the config path to there?
Thanks!
Edit:
In the class typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php at line 393 I found the translation path hard-coded. So I need to inherit from this class and register it as my new selectMultipleSideBySide in the TCA.
I copied the class TYPO3.CMS/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php to my extension in Classes/From/Element/SelectTagCloudElement.php
I adapted namespace to my extensions.
I add a use-directive of use TYPO3\CMS\Backend\Form\Element\SelectMultipleSideBySideElement;.
I adapt the translation string like in line 221 to my custom records translation xml file.
I found on https://docs.typo3.org/m/typo3/reference-coreapi/8.7/en-us/ApiOverview/FormEngine/Rendering/Index.html a snippet to register an new NodeType (the class I extended previously) using:
// Add new field type to NodeFactory
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1487112284] = [
'nodeName' => 'selectTagCloud',
'priority' => '70',
'class' => \MyVendor\CoolTagCloud\Form\Element\SelectTagCloudElement::class,
];
in ext_localconf.php
Now I can use selectTagCloud instead of selectMultipleSideBySide in the TCA.
"Dump Autoload Information" in the Install Tool
Done

how to disable fields in tca only for certain ctypes

I want to disable certain fields in the backend, e.g. many fields of gridelements and other content elements. I know about the possibilities of TCEFORM but it allowes only to disable a field in all cTypes. I need a way to disable certain field only for certain cTypes.
Is there a way to achieve this?
Thanks
You have full control over which field are shown, if you adapt TCA for tt_content. You can override TCA with your customer extensions (sitepackage).
The following file contains fields, which are shown for CType header (TYPO3 CMS 7.6)
EXT:sitepackage/Configuration/TCA/Overrides/tt_content.php
<?php
defined('TYPO3_MODE') or die();
call_user_func(function () {
$GLOBALS['TCA']['tt_content']['types']['header']['showitem'] = '--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,rowDescription,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.extended,--div--;LLL:EXT:lang/locallang_tca.xlf:sys_category.tabs.category,categories';
});
Remove or add any fields after your needs and do so for any CType you wish to change.
See also https://docs.typo3.org/typo3cms/TCAReference/7.6/Reference/Types/Index.html
Meanwhile (since 9 LTS) it is possible via TsConfig:
TCEFORM.tt_content.subheader.types.text.disabled = 1
… disables the subheader field for all text content elements.
You can even disable a field for all cTypes and define an exception:
TCEFORM.tt_content.subheader{
disabled = 1
types.text.disabled = 0
}
As long as you don't need additional conditions like i.e. a certain user or group or a particular branch of the page tree to disable these fields, you should not go for PageTSconfig and TCEFORM but pure TCA types instead.
Just create a site package extension, which would be recommended anyway, and make sure to provide the desired setup for the tt_content table within Configuration/TCA/Overrides/tt_content.php so it will be applied automatically.
You can find some slides about the "Anatomy of Sitepackages" here: https://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages
Additional information about the TCA types can be found here:
https://docs.typo3.org/typo3cms/TCAReference/Types/Index.html
As Gridelements just provides mandatory fields for layout, children, container and column, you should not disable these fields though, since it might break the functionality.

TYPO3: Custom content element - TCA fields configuration

I followed a tutorial to implement custom content elements in TYPO3. I don't understand how to configure backend fields.
Here is my override for tt_content:
$GLOBALS['TCA']['tt_content']['types']['my_custom_ce'] = [
'showitem' => '
--palette--;' . $frontendLanguageFilePrefix . 'palette.general;general,
--linebreak--, header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header_formlabel,
--linebreak--, date;Datum,
--linebreak--, media;Media,
--linebreak--, bodytext;text,
];
I would like for example to change the textarea size for the "bodytext" field. I read the official TCA reference but still don't get how this is working
The change of textarea fild size is done in
$GLOBALS['TCA']['tt_content']['columns']['bodytext']['config'] etc.
Look for details in the TCA reference.
This changes the field size for all CEs. As far as I know it is not possible to change this only for one CE.

How to enable header_position in TYPO3 7.6

In versions prior to TYPO3 7.6 you could select a position for your header within your content element (left, middle, right as far as I remember).
The field which has been used for storing that information in tt_content header_position is still available.
However, it will not appear in the backend.
I'm also using fluid_styled_content for rendering my content, and the Header partial doesn't contain any reference to the position, but only to the layout field.
My question is: How can I reenable that field and use it to position my headers?
You have to build a quick extension of yours which can reenable the field. You need to create folders and a file like following:
your_ext/Configuration/TCA/Overrides/tt_content.php
the contents of that file are:
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
ExtensionManagementUtility::addTCAcolumns('tt_content',[
'header_position' => [
'exclude' => 1,
'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.left', 'left'],
['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.right', 'right'],
['LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tt_content.header_position.center', 'center']
]
]
]
]);
ExtensionManagementUtility::addFieldsToPalette('tt_content', 'header', '--linebreak--,header_position', 'after:header_layout');
ExtensionManagementUtility::addFieldsToPalette('tt_content', 'headers', '--linebreak--,header_position', 'after:header_layout');
Now the field should be back in the backend, because you've added it to the TCA via addTCAColumns to the tt_content configuration and added it via addFieldsToPalette to the header and headers palettes of tt_content, which are used by the types textmedia and header.
You can find out more about this by using the Configuration module in the TYPO3 backend. You can see it, when you are logged in as admin. Also a good place to look and learn about the TCA is the TCA reference: https://docs.typo3.org/typo3cms/TCAReference/
Now you need to alter the fluid_styled_content templates. You need to create template overrides for the header partial of fluid_styled_content.
First create a folder: your_ext/Configuration/TypoScript and add a setup.txt and a constants.txt file.
In setup.txt add the following lines:
lib.fluidContent{
templateRootPaths{
10 = {$plugin.your_ext.view.fluid_styled_content.templateRootPath}
}
partialRootPaths{
10 = {$plugin.your_ext.view.fluid_styled_content.partialRootPath}
}
layoutRootPaths{
10 = {$plugin.your_ext.view.fluid_styled_content.layoutRootPath}
}
}
In constants.txt do:
plugin.your_ext{
view{
fluid_styled_content{
templateRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Templates/
partialRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Partials/
layoutRootPath = EXT:your_ext/Resources/Private/FluidStyledContent/Layouts/
}
}
}
To enable your TypoScript, you need to add a ext_tables.php in your your_ext folder and give it the following one-liner:
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY,'Configuration/TypoScript', 'Your Ext Template');
You need to include your static TypoScript to your page via the Template module to enable the change to fluid_styled_content
Now you can copy the templates you need from
typo3/sysext/fluid_styled_content/Resources/Private/Templates
typo3/sysext/fluid_styled_content/Resources/Private/Partials
typo3/sysext/fluid_styled_content/Resources/Private/Layouts
into your extensions folders you need to create:
your_ext/Resources/Private/FluidStyledContent/Templates
your_ext/Resources/Private/FluidStyledContent/Partials
your_ext/Resources/Private/FluidStyledContent/Layouts
Now you can alter the templates. For your header_position field, you probably just need to copy
typo3/sysext/fluid_styled_content/Resources/Private/Partials/Heaeder.html
to
your_ext/Resources/Private/FluidStyledContent/Partials/Header.html
and add your selected value as {data.header_position} to a div class and style that.
Keep in mind you do not need to copy all of the templates, because with the TypoScript you just defined another location for fluid to search for templates and take them, if they are available. If not, fluid will walk back the chain and take the templates that are defined at position 9 and lower. You can look into the TypoScript Object Browser by the Template module and look into the TypoScript variable lib.FluidContent to see, if your TypoScript include has worked.
Hope this helped a bit ;)
The database field header_position is only included in the TYPO3 core extension css_styled_content. If you don't have that extension installed the field in the database is probably there because it was installed sometime before.
It is not advised to install css_styled_content and fluid_styled_content installed in parallel as some options can conflict.
If you want to use fluid_styled_content and have the header_position field available the best way to go would be to create a very small TYPO3 extension yourself that includes the necessary SQL definition for the column header_position, the appropriate TCA configuration for that column and a few bits of TypoScript to extend/override the „Partial” paths of fluid_styled_content.