Skip to content

Commit

Permalink
[FEATURE] Add a basic content element
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Sep 7, 2024
1 parent fa17c59 commit ff77768
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Configuration/Sets/Examples/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

@import 'EXT:examples/Configuration/TypoScript/TSref/*.typoscript'

@import 'EXT:examples/Configuration/TypoScript/CustomContentElements/Step1.typoscript'
@import 'EXT:examples/Configuration/TypoScript/CustomContentElements/Step2.typoscript'
@import 'EXT:examples/Configuration/TypoScript/CustomContentElements/*.typoscript'

@import 'EXT:examples/Configuration/TypoScript/DataProcessors/General.typoscript'
@import 'EXT:examples/Configuration/TypoScript/DataProcessors/Processors/*.typoscript'
Expand Down
46 changes: 46 additions & 0 deletions Configuration/TCA/Overrides/tt_content_basic_content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

call_user_func(function () {

$key = 'examples_basiccontent';

// Adds the content element to the "Type" dropdown
ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'label' => 'Example - basic content',
'value' => $key,
'group' => 'default',
],
'textmedia',
'after',
);

// Configure the default backend fields for the content element
$GLOBALS['TCA']['tt_content']['types'][$key] = [
'showitem' => '
--palette--;;headers,
bodytext,
',
];
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tt_content {
examples_basiccontent =< lib.contentElement
examples_basiccontent {
templateName = BasicContent
}
}
12 changes: 12 additions & 0 deletions Resources/Private/Templates/ContentElements/BasicContent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="Main">

<div class="examples-basic-content">
<f:format.nl2br>
{data.bodytext}
</f:format.nl2br>
</div>

</f:section>
</html>

0 comments on commit ff77768

Please sign in to comment.