简体   繁体   English

错字3:是否可以为扩展程序制作自定义flexform?

[英]Typo3: Is it possible to make a custom flexform for an extension?

I'm making an extension where the user is able to post posts. 我正在进行扩展,用户可以发布帖子。 But I want the extension to be dynamic so that for example on one page the user can upload pictures where as on another page the user can not upload pictures but some text. 但我希望扩展是动态的,以便例如在一个页面上用户可以上传图片,而在另一个页面上,用户不能上传图片而是上传一些文本。

I want to be able to create a template for the plugins backend and one for the frontend that you can modify for each use of the plugin. 我希望能够为插件后端创建一个模板,并为前端创建一个模板,您可以为插件的每次使用修改该模板。 I know there is flexform but with that the user of the plugin has to modify the plugin... 我知道有flexform但是插件的用户必须修改插件...

Is is possible and if so, how can I do it? 是可能的,如果是的话,我该怎么做?

You should be able to modify the TCA for the field pi_flexform before its rendered by using some of the existing hooks in the core methods, thus changing what XML file (containing flexform configuration) is loaded for your plugin. 您应该能够通过使用核心方法中的一些现有挂钩来修改字段pi_flexform之前的TCA,从而更改为插件加载的XML文件(包含flexform配置)。 As this is page config, it can be different for each page but it can be inherited by subpages. 由于这是页面配置,因此每个页面可能不同,但可以通过子页面继承。

While class.t3lib_tceforms.php contains lots of hooks, I believe that for changing TCA on the fly you will have to use a different one: postUserLookUp in t3lib/class.t3lib_userauth.php . 虽然class.t3lib_tceforms.php含有大量的钩,我认为,在飞行改变TCA你将不得不使用一个不同: postUserLookUpt3lib / class.t3lib_userauth.php。

  1. Create a class that would contain method modifying TCA and register it in ext_localconf.php : $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['postUserLookUp'][] = 'EXT:YOUR_EXTENSION/class.YOUR_CLASS.php:YOUR_CLASS->YOUR_METHOD'; 创建一个包含修改TCA方法并在ext_localconf.php中注册的$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['postUserLookUp'][] = 'EXT:YOUR_EXTENSION/class.YOUR_CLASS.php:YOUR_CLASS->YOUR_METHOD';

  2. In your custom method override TCA for $TCA['tt_content']['columns']['pi_flexform']['config']['ds']['YOUR_EXTENSION_pi1,list'] by a value that your admin sets in a page config. 在您的自定义方法中,为$TCA['tt_content']['columns']['pi_flexform']['config']['ds']['YOUR_EXTENSION_pi1,list']管理员设置的值为页面配置。 t3lib_BEfunc::getModTSconfig() should let you load page config and it's up to you to decide what key you will be looking for. t3lib_BEfunc::getModTSconfig()应该允许你加载页面配置,由你来决定你要找的是什么键。

NOTE : This is untested theory but its principle is based on one of my custom extensions where I modify TCA on the fly. 注意 :这是未经测试的理论,但其原理基于我的一个自定义扩展,我可以动态修改TCA。

Have a look at EXT:flux. 看看EXT:flux。 Claus did that already. 克劳斯已经这样做了。 https://github.com/FluidTYPO3/flux https://github.com/FluidTYPO3/flux

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

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