Add another picture to content element in typo3 - typo3

I'm creating my own content element to display some text, some image and another image. This is my tt_content.php file.
'logo' => [
'label' => 'dfasad',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'logo',
[
'overrideChildTca' => [
'types' => [
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
'showitem' => '
--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
],
],
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
This gives me an input field on the backend but it does not get saved on the db.
Probably I need to set that too, right?
I've seen the documentation but is not clear for, I can copy and paste the code and even if would work I would never know why.

You need to define a database field in the ext_tables.sql file of your extension.
CREATE TABLE mytablename (
logo int(11) DEFAULT '0' NOT NULL,
);
You need to set mytablename to the name of the table you're extending or your own table name.
See the documentation for details.

Related

TYPO3 new tab to custom extension

I write my own extension. I have the file tx_xyz_domain_model_abc.php
with following code:
'types' => [
'1' => [
'showitem' => '
--div--;Article, title,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, sys_language_uid, l10n_parent, l10n_diffsource,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, starttime, endtime,
'],
],
so the first line is my new field. The other lines are TYPO3 defaults. A --div-- is a new tab. How can i add the media or general tab to my extension?
I've tried to add
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
But there is no new tab. How can i do this?
--palette--; will insert a new palette (=grouped fields) to the current tab (-> TCA ref).
Without defining a tab, the fields are automatically put in a "General"-Tab at first position.
'types' => [
'0' => [
'showitem' => '
hidden, title,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.images, image1, image2,
'
],
],
For further tabs, you need to insert a "--div--;label"-value in the field list (-> TCA ref):
'types' => [
'0' => [
'showitem' => '
hidden, title,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.text, description, teaser,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.images, image1, image2,
'
],
],
To show the core general tab in your extension is not possible. You wrote your own extension with your own data model. This is saved in db table tx_xyz_domain_model_abc. But data in core are from table tt_content which has a separate TCA.
You can
Extend table tt_content with your extension. Then you can use fields from tt_content
Add fields like header in your extension and table

get mergedProperties of sys_file_reference in tx_news

I am using TYPO3 9.5.26 with tx_news 8.5.2. I have extended sys_file_reference with my own field. I can access this fields value in my fluid templates like so:
{file.properties.tx_myext_frame}
This is tested and works fine. However in the news module this stays empty
{mediaElement.properties.tx_myext_frame}
How can I use the orginalFile properties in tx_news?
Thanks
Code I use to add the field:
typo3conf\ext\myext\ext_tables.sql
CREATE TABLE sys_file_reference (
tx_myext_frame tinyint(4) DEFAULT '0' NOT NULL,
);
typo3conf\ext\myext\Configuration\TCA\Overrides\sys_file_reference.php
// Add some fields to sys_file_reference table
$temporaryColumns = [
'tx_myext_frame' => [
'exclude' => 0,
'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:tx_myext_frame',
'config' => [
'type' => 'check',
'default' => '0',
]
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'sys_file_reference',
'imageoverlayPalette',
'--linebreak--,tx_myext_invert,tx_myext_frame',
'after:description'
);
found the answer myself just now - so for anyone trying this use
{mediaElement.originalResource.properties.tx_myext_frame}

How to add file collection record programatically in custom extension in TYPO3

I want to add the file collection record programatically in a custom record I have created in the backend.
I can add separate files right now after I created a custom model which had the file property, but I cannot control which folder it goes to right now, so I want to instead make a file collection type of record inside my custom model so I can have more control over which folder the file gets uploaded.
Any help is appreciated. Thank you
If someone else stumbles upon this, here is how I did it.
'files' => [
'exclude' => 0,
'label' => 'Files',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( 'files',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference',
],
// custom configuration for displaying fields in the overlay/reference table
// to use the imageoverlayPalette instead of the basicoverlayPalette
'foreign_match_fields' => [
'fieldname' => 'files',
'tablenames' => 'tx_table_name',
'table_local' => 'sys_file',
],
] ),
],

TYPO3 - Accessing detail page of record via url GET parameter

I developed an extbase extension with list and detail view (list and show action). Without using realurl ... the link of a detail view looks like this:
domain/index.php?id=43&/?tx_abc_abc[record]=1&tx_abc_abc[action]=show&tx_abc_abc[controller]=Abc
And when I change the record id in the url I can dynamically change the content on the detail page and access the record:
domain/index.php?id=43&/?tx_abc_abc[record]=2&tx_abc_abc[action]=show&tx_abc_abc[controller]=Abc
domain/index.php?id=43&/?tx_abc_abc[record]=3&tx_abc_abc[action]=show&tx_abc_abc[controller]=Abc
domain/index.php?id=43&/?tx_abc_abc[record]=4&tx_abc_abc[action]=show&tx_abc_abc[controller]=Abc
The final goal is having a url looking like this and access the record via the GET parameter in the url:
domain/abc/?abc=1
domain/abc/?abc=2
domain/abc/?abc=3
domain/abc/?abc=4
But when activating realurl ... I cannot directly access the record if its not available in tx_realurl_urldata. Or how should the realurl setup look like?
What's the best solution for this? I have too many records (plus 2 languages) for the links to be written and always available in tx_realurl_urldata.
So my thought was to deactivate realurl for this specific extension? But how?
Or I thought to exclude the detail page in realurl_conf.php: 'excludePageIds' => 42,43 but that did not work.
I made a realurl configuration for my own extension for detail pages like this:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = [
'www.domain.ch' => [
...
],
'fixedPostVars' => [
'extYourextensionDetailConfiguration' => [
[
'GETvar' => 'tx_yourextension_abc[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_yourtextension_abc[abc]',
'lookUpTable' => [
'table' => 'tx_yourextension_domain_model_abc',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND deleted=0 AND hidden=0',
'useUniqueCache' => true,
'useUniqueCache_conf' => [
'strtolower' => true,
'spaceCharacter' => '-',
],
'enable404forInvalidAlias' => true,
],
],
],
...,
'99' => 'extYourextensionDetailConfiguration',
...,
],
...,
],
];
Where
www.domain.ch is your domain
extYourextensionDetailConfiguration is a name to use later
alias_field is the content of the segment. can be ID if you want to switch between changing the URL handmade
99 is the ID of the page with the detail view

TYPO3 - Extension TCA - Show backend fields

I'm deveopping my own Typo3 extension and it's not as easy as expected :)
When i create an object in the backend it's working :
But I can't find a way to display the following commands :
move up
move down
enable/disabled
Here is what I tried to show the "enable/disable" icon :
$TCA['tx_productsfaq_domain_model_scenario'] = array (
'ctrl' => array (
'enablecolumns' => [
'disabled' => 'hidden'
]
)
);
.. with no success. In my database the model has a "hidden" column (tinyint). Maybe I forgot something ? All other properties in my TCA work fine.
You need a sorting field in your Database
CREATE table tx_productsfaq_domain_model_scenario (
...
sorting int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,
...
);
and TCA configuration like
$TCA['tx_productsfaq_domain_model_scenario'] = array (
'ctrl' => [
...
'sortby' => 'sorting',
'enablecolumns' => [
'disabled' => 'hidden'
],
...
]
);
It seems you are using the old way to configure your TCA. Please see https://docs.typo3.org/typo3cms/TCAReference/Introduction/Index.html
Use EXT:productsfaq/Configuration/TCA/tx_productsfaq_domain_model_scenario.php
return [
'ctrl' => [
...
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
],
...
],
'interface' => [
'showRecordFieldList' => 'hidden, ...'
],
'types' => [
'0' => ['showitem' => 'hidden, ...']
],
'columns' => [
...
]
];
Depending on your TYPO3 version move up, move down will be visible if you switch on extended view and have defined a sorting field (by default it is called sorting with type int).
To have the correct fields and options for sorting and hiding you may use the EXT:extension_builder and generate a dummy extension to identify these fields.
Compare your definition and declaration of the fields ('sorting', 'hidden') in TCA and SQL(!) to a build in table like tt_content.