简体   繁体   中英

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

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

  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';

  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. t3lib_BEfunc::getModTSconfig() should let you load page config and it's up to you to decide what key you will be looking for.

NOTE : This is untested theory but its principle is based on one of my custom extensions where I modify TCA on the fly.

Have a look at EXT:flux. Claus did that already. https://github.com/FluidTYPO3/flux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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