Styles TYPO3:如何为自己的后端内容元素(ContentPreviewRender)创建css和模板文件
因此,我创建了一个自己的内容元素(Foundation Button),并注册了它自己的图标以及应该在后端显示的内容。现在我仍然缺少的是每个内容的样式和模板。我在网上找到了一个例子,我想知道它是如何做到的。我在网上找不到任何关于如何实现这一目标的指南 这是我的内容元素 这就是我希望它在后端显示的方式 由于我不知道如何实现这一点,我不确定应该在这里发布什么代码,但我可以发布我的按钮previewrendereder.phpStyles TYPO3:如何为自己的后端内容元素(ContentPreviewRender)创建css和模板文件,styles,typo3,backend,Styles,Typo3,Backend,因此,我创建了一个自己的内容元素(Foundation Button),并注册了它自己的图标以及应该在后端显示的内容。现在我仍然缺少的是每个内容的样式和模板。我在网上找到了一个例子,我想知道它是如何做到的。我在网上找不到任何关于如何实现这一目标的指南 这是我的内容元素 这就是我希望它在后端显示的方式 由于我不知道如何实现这一点,我不确定应该在这里发布什么代码,但我可以发布我的按钮previewrendereder.php <?php namespace Vendor\BwSeitena
<?php
namespace Vendor\BwSeitenameBase\Hooks\PageLayoutView;
/*
* 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\Backend\View\PageLayoutViewDrawItemHookInterface;
use \TYPO3\CMS\Backend\View\PageLayoutView;
/**
* Contains a preview rendering for the page module of CType="yourextensionkey_newcontentelement"
*/
class ButtonPreviewRenderer 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'] === 'foundation_button') {
$headerContent = '<strong>' . $parentObject->CType_labels[$row['CType']] . '</strong><br/>';
$itemContent .= '<strong>Text:</strong> ' . $parentObject->linkEditContent($parentObject->renderText($row['texting']), $row) . '<br />';
$itemContent .= '<strong>Link:</strong> ' .$parentObject->linkEditContent($parentObject->renderText($row['linking']), $row) . '<br />';
$drawItem = false;
}
}
}
有后端CSS API:
您应该能够通过以下方式将CSS注入后端:
$GLOBALS['TBE_STYLES']['stylesheet'] = 'EXT:your/file/location.css';
这是一个解决方案,也是我投+1票的原因。我应该把我的问题安排得更好。我想为每个元素有一个模板文件了。所以,我编辑了我的问题。如果我知道如何将模板文件直接分配给每个内容元素,那就太好了。谢谢你的回答!