TYPO3: How to configure plugin preview in Backend

心已入冬 提交于 2019-12-23 04:38:33

问题


In the backend I want to display some configurations of the plugin the editor has selected. Like in powermail or news plugin. How can this be achieved?


回答1:


You'd apply the same logic as for a custom preview of any custom element:

  • You can 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
    
  • Alternatively you can implement the tt_content_drawItem hook:

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

    And then implement this hook:

    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
        }
    }
    


来源:https://stackoverflow.com/questions/55691663/typo3-how-to-configure-plugin-preview-in-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!