【问题标题】:TYPO3: How to configure plugin preview in BackendTYPO3:如何在后端配置插件预览
【发布时间】:2019-04-15 14:42:20
【问题描述】:

在后端我想显示编辑器选择的插件的一些配置。就像在 powermail 或新闻插件中一样。如何实现?

【问题讨论】:

    标签: typo3 backend extbase


    【解决方案1】:

    您将应用与 custom preview of any custom element 相同的逻辑:

    • 您可以use PageTS to register a custom Fluid template:

      // Register preview for a custom content element
      mod.web_layout.tt_content.preview.my_content_element = EXT:my_ext/Resources/Private/Templates/Preview/MyContentElement.html
      // Register preview for a plugin
      mod.web_layout.tt_content.preview.list.myext_myplugin = EXT:my_ext/Resources/Private/Templates/Preview/MyPlugin.html
      
    • 或者你可以实现tt_content_drawItem钩子:

      $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['fluid_styled_slider'] = \Acme\Package\MyPreviewRenderer::class;
      

      然后实现这个钩子:

      namespace Acme\Package;
      
      use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
      
      class MyPreviewRenderer implements PageLayoutViewDrawItemHookInterface
      {
          /**
           * ...
           */
          public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
          {
              // 1. Check $row['CType'] for your content element and $row['list_type'] for your plugin in case of "list"
              // 2. Fill $itemContent with your preview
              // 3. Set $drawItem = false; to prevent rendering of the default preview
          }
      }
      

    【讨论】:

    • 我无法确认这些选项是否有效。我认为上面提到的配置期望 CType 是相关的修饰符。但在插件的情况下,它是 list_type,CType 始终是“list”。
    • 没错,我已经添加了更多细节。
    • 那么对于选项A,PageTs的修改,好像没有选项?
    • 另一个很棒的建议,我也为此添加了一个示例。另外我已经在 TYPO3v9 中链接了相关的源代码。
    • 至少对于 Typo3 v10,您还必须另外设置 mod.web_layout.tt_content.preview.list = 1,否则您的 Fluid 预览将不起作用。您必须这样做,因为核心检查数组 ['mod']['web_layout']['tt_content']['preview']['list'] 是否存在。没有这个设置,只会设置['list.']
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多