TYPO3 8.7.16 Добавление пользовательского содержимого слайдера

Я хотел бы создать пользовательский элемент контента на TYPO3 8.7.16, но все руководства, которые я видел до сих пор, либо устарели, либо некоторые настройки не применяются к текущей версии TYPO3. Так что для этого примера, если бы кто-нибудь мог указать мне правильное направление, я был бы очень признателен.

Концепт

Я хотел бы построить слайдер:

  • выбрав изображения с FAL.
  • с заголовком
  • с богатым текстом

Пока у меня есть это:

TSconfig

mod.wizards.newContentElement.wizardItems.my_slider {
header = Slider
after = common
elements {
my_slider {
iconIdentifier = EXT:ak_extension_base/Resources/Public/Icon/Slider.svg
title = Slider
description = Create a Slider
tt_content_defValues {
CType = my_slider
}
}
}
show := addToList(my_slider)
}

Конфигурация / ТС / Переопределение / tt_content.php

(Чтобы сделать его видимым в списке, когда он выбран)

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'Slider',
'my_slider',
'EXT:ak_extension_base/Resources/Public/Icons/Slider.svg'
),
'CType',
'ak_extension_base'
);

В том же файле я получил следующий код:

$GLOBALS['TCA']['tt_content']['types']['my_slider'] = array(
'showitem' => '
--div- -;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--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,
image;Slider_Image,
bodytext;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext_formlabel,
--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,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
',
'columnsOverrides' => [
'bodytext' => [
'config' => [
'enableRichtext' => true,
'richtextConfiguration' => 'default'
]
],
'image' => [
'label' => 'Slider Image',
'config' => [
'type' => 'inline',
],
],
]
);

Все отлично работает до сих пор. Я получаю слайдер на собственной вкладке, я все понимаю правильно.

  1. Вопрос: Как я могу добавить изображения на columnsOverrides?

РЕДАКТИРОВАТЬ: Я нашел способ добавить изображения на TCA.

Теперь я хочу создать шаблон для этого элемента контента (слайдер). Я знаю, что должен включить статический файл. Итак, я сделал это:

TCA / Заменяет / sys_template.php

<?php
// Add an entry in the static template list found in sys_templates for static TS
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'ak_extension_base',
'Configuration/TypoScript',
'Include Slider'
);
?>

С этим я получаю статический шаблон в списке, и я могу включить его.

Теперь мне нужно объявить мой шаблон жидкости так на TypoScript у меня есть следующее:

tt_content {
my_slider < lib.contentElement
my_slider {
templateName = Slider
dataProcessing {
1 = Vendor\AkExtensionBase\DataProcessing\SliderProcessor
1 {
useHere = theConfigurationOfTheDataProcessor
}
}
}
}

Сначала у меня был этот SliderProcessor как NewContentElementProcessor, и когда я добавил свой элемент содержимого, возникла ошибка, сообщающая, что NewContentElementProcessor не существует. Так что я исправил это, а затем, после этого у меня был Ошибка 500. Так что где-то после этого у меня что-то неправильно настроено. Это остальная часть моего кода.

TypoScript

lib.contentElement {
templateRootPaths {
200 = EXT:ak_extension_base/Resources/Private/Templates/
}
}

Классы / обработка данных / SliderProcessor.php

<?php
namespace Vendor\AkExtensionBase\DataProcessing;

use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;

class SliderProcessor implements DataProcessorInterface
{

/**
* Process data for the content element "My new content element"*
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array $contentObjectConfiguration The configuration of Content Object
* @param array $processorConfiguration The configuration of this processor
* @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
* @return array the processed data as key/value store
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
)
{
$processedData['slider'] = 'This variable will be passed to Fluid';

return $processedData;
}
}

Классы / Крючки / PageLayoutView / SliderPreviewRender.php

<?php
namespace Vendor\AkExtensionBase\Hooks\PageLayoutView;

use \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use \TYPO3\CMS\Backend\View\PageLayoutView;

class SliderPreviewRenderer implements PageLayoutViewDrawItemHookInterface
{

/**
* Preprocesses the preview rendering of a content element of type "My new content element"*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*
* @return void
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
)
{
if ($row['CType'] === 'my_slider') {
$itemContent .= '<p>We can change our preview here!</p>';

$drawItem = false;
}
}
}

Ресурсы / Private / Templates / Slider.html

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"data-namespace-typo3-fluid="true">

<h1>{slider}</h1>
</html>

Так есть идеи, что я делаю не так? Есть ли другой способ, о котором я не думаю?

РЕДАКТИРОВАТЬ Я могу сузить свою проблему до обработки данных. Где-то по пути я запутался. Например, я понятия не имею, какова конфигурация процессора данных на tt_content.

РЕДАКТИРОВАТЬ 2 Я нашел способ показать все на FrontEnd.

Шаги были приняты к действию после этой документации.
Dokumentation

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector