简体   繁体   English

从扩展中添加TYPO3后端布局

[英]Adding TYPO3 backend layout from an extension

I am developing a template for TYPO3 version 7. In the backend I've created several backend layouts. 我正在开发TYPO3版本7的模板。在后端,我创建了几个后端布局。 In my template (extension) in the setup.ts I check for the IDs of the backend layout to deliver the correct fluidtemplate. 在setup.ts的模板(扩展名)中,我检查后端布局的ID以提供正确的FluidTemplate。

For a more easy use of the template I want to deliver the backend layouts directly with the extension. 为了更轻松地使用模板,我想直接使用扩展名交付后端布局。 How to add backend layouts directly from an extension? 如何直接从扩展中添加后端布局? How to get or set an id for the backend layouts? 如何获取或设置后端布局的ID? So I can map this in my setup.ts? 这样我可以在setup.ts中映射它吗?

I normally store the Backend-Layouts in folders to structure the extension. 我通常将Backend-Layouts存储在文件夹中以构造扩展名。

  • BackendLayouts/ in which all Backend-Layouts are saved BackendLayouts /保存所有Backend-Layouts
  • BackendLayouts.ts this is where the Layouts are brought together ( <INCLUDE_TYPOSCRIPT: source="Path/To/Backendlayout"> ) BackendLayouts.ts,这是将布局放在一起的地方( <INCLUDE_TYPOSCRIPT: source="Path/To/Backendlayout">

Image: Screenshot of the Structure of the Example 图片: 示例结构的屏幕截图

Layout-Setup 布局设置

The basic Setup for a BE-Layout looks like this: BE布局的基本设置如下所示:

mod.web_layout.BackendLayouts{
    exampleKey {

        title = Example
        config{
            # Here you paste the generated BE-Layout
        }
    }
}

For example (Default.ts): 例如(Default.ts):

mod.web_layout.BackendLayouts{
    default{
        title = Default
        config{
            backend_layout {
                colCount = 2
                rowCount = 2
                rows {
                    1 {
                        columns {
                            1 {
                                name = Slider
                                colspan = 2
                                colPos = 1
                            }
                        }
                    }
                    2 {
                        columns {
                            1 {
                                name = Sidebar
                                colPos = 2
                            }
                            2 {
                                name = Content
                                colPos = 0
                            }
                        }
                    }
                }
            }
        }
    }
}

At last you need to register your Page configuration: 最后,您需要注册您的Page配置:

<?php
  if (!defined('TYPO3_MODE')) {
          die ('Access denied.');
  }


  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
          'test_ext',
          'Configuration/TypoScript/Backend/BackendLayouts.ts',
          'My special Backend Layouts'
  );
?>

This only works for Typo3 v7.4.x and higher 这仅适用于Typo3 v7.4.x及更高版本

Typo3 Backend Typo3后端

  1. Clear cache and reload Backend 清除缓存并重新加载后端
  2. Go to the root-Page and edit it 转到根页面并对其进行编辑
  3. Go to the "Resource" Tab and add your TypoScript Configuration 转到“资源”选项卡并添加您的TypoScript配置
  4. Save, Reload Page 保存,刷新页面

Now you should be able to see your added Backend Layouts when you edit a page. 现在,您应该可以在编辑页面时看到添加的后端布局。

Further Actions 进一步行动

If you want to use differnt Templates for every BE-Layout, you can simply do this via the "templateName" porperty in your FLUIDTEMPLATE setup as you can see here: Official TypoScript reference, #templateName 如果要为每个BE布局使用不同的模板,则只需通过FLUIDTEMPLATE设置中的“ templateName”属性即可完成此操作,如此处所示: 官方TypoScript参考,#templateName

You can provide a class that implements the DataProviderInterface for backend layouts. 您可以提供一个为后端布局实现DataProviderInterface的类。 You must then register that class under the key 然后,您必须在密钥下注册该课程

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['BackendLayoutDataProvider'][$_EXTKEY] = 'Fully\\Qualified\\Namespace\\Of\\The\\Class';

This is possible since TYPO3 6.2. 从TYPO3 6.2开始这是可能的。

More references: 更多参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM