Skip to content

Instantly share code, notes, and snippets.

@helhum
Created August 18, 2023 13:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helhum/9028fd8fb864c9b0cbd6585d3f082404 to your computer and use it in GitHub Desktop.
Save helhum/9028fd8fb864c9b0cbd6585d3f082404 to your computer and use it in GitHub Desktop.
Add Topwire fields to tt_content elements
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
(static function (): void {
$columns = [
'tx_turbo_wrap_in_frame' => [
'label' => 'Wrap in Turbo frame',
'config' => [
'type' => 'check',
],
],
'tx_turbo_propagate_url' => [
'label' => 'Propagate URL',
'config' => [
'type' => 'check',
],
],
'tx_turbo_morph' => [
'label' => 'Morph',
'config' => [
'type' => 'check',
],
],
'tx_turbo_frame_id' => [
'label' => 'Frame id',
'config' => [
'type' => 'input',
],
],
'tx_turbo_scope_frame' => [
'label' => 'Scope frame id',
'config' => [
'type' => 'check',
],
],
'tx_turbo_show_when_match' => [
'label' => 'Only show element when scope matches',
'config' => [
'type' => 'check',
],
],
];
ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$columns,
);
ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'--div--;Topwire,tx_turbo_wrap_in_frame,tx_turbo_frame_id,tx_turbo_scope_frame,tx_turbo_propagate_url,tx_turbo_morph,tx_turbo_show_when_match',
);
})();
tt_content.stdWrap.turboFrameWrap.field = tx_turbo_wrap_in_frame
tt_content.stdWrap.turboFrameWrap.frameId.field = tx_turbo_frame_id
tt_content.stdWrap.turboFrameWrap.scopeFrame.field = tx_turbo_scope_frame
tt_content.stdWrap.turboFrameWrap.propagateUrl.field = tx_turbo_propagate_url
tt_content.stdWrap.turboFrameWrap.morph.field = tx_turbo_morph
tt_content.stdWrap.turboFrameWrap.path = tt_content
CREATE TABLE tt_content (
tx_turbo_wrap_in_frame tinyint(4) unsigned DEFAULT '0' NOT NULL,
tx_turbo_propagate_url tinyint(4) unsigned DEFAULT '0' NOT NULL,
tx_turbo_morph tinyint(4) unsigned DEFAULT '0' NOT NULL,
tx_turbo_frame_id text,
tx_turbo_scope_frame tinyint(4) unsigned DEFAULT '0' NOT NULL,
);
@Chrisswald
Copy link

tx_turbo_show_when_match is missing in ext_tables.sql and typoscript

@Chrisswald
Copy link

I added

tx_turbo_show_when_match tinyint(4) unsigned DEFAULT '0' NOT NULL,

and

tt_content.stdWrap.turboFrameWrap.turboShowWhenMatch.field = tx_turbo_show_when_match

to make it work.

@helhum
Copy link
Author

helhum commented Aug 26, 2023

@Chrisswald What do you use this experimental (and undocumented) feature for? I was considering removing it tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment