dtb81443 2013-10-31 08:47
浏览 31

从控制器中的FlexForms获取TYPO3插件设置

I have a FE Plugin which uses a FlexForm MyExtFlexForm which is used to set certain configurations like limit or SourcePage etc..

In my controller action list I get these settings using $this->settings. Works fine till now.

Now, I make AJAX calls to action update and I need to use the same settings which have been set earlier through the FlexForm for the FE plugin on this page. $this->settings does not show anything.

I checked $GLOBALS['TSFE']->tmpl->setup['plugin']['MyExt.']['settings.'] and none of the settings defined in FlexForm show here.

How do I solve this issue?

EDIT:

My sample Flexform looks like this:

<sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>View Settings</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <switchableControllerActions>
                        <TCEforms>
                            <label>Select</label>
                            <config>
                                <type>select</type>
                                <items>
                                    <numIndex index="0">
                                        <numIndex index="0">MyFunction</numIndex>
                                        <numIndex index="1">MyExt->list</numIndex>
                                    </numIndex>
                                </items>
                            </config>
                        </TCEforms>
                    </switchableControllerActions>

                    <settings.flexform.limit>
                        <TCEforms>
                            <label>Number of items to be displayed</label>
                            <config>
                                <type>input</type>
                                <size>10</size>
                            </config>
                        </TCEforms>
                    </settings.flexform.limit>
                </el>
            </ROOT>
        </sDEF>
    </sheets>

Then I make an AJAX call to my controller action and print this $this->settings , shows no settings.

  • 写回答

2条回答 默认 最新

  • dozr162106 2013-10-31 10:01
    关注

    The easiest solution is proper naming fields in FlexForm ie, if your field will be prefixed with settings. it will be visible in $this->settings array:

    <settings.myField>
        <TCEforms>
            <label>My very special setting</label>
            <config>
                <type>input</type>
            </config>
        </TCEforms>
    </settings.myField>
    

    Controller:

    $mySetting = $this->settings['myField'];
    

    On the other hand if you're planning to merge TS settings with FlexForm settings you can prefix it additionaly with some other word like: <settings.flexform.myField> and then access it:

    $fromTypoScript = $this->settings['myField'];
    $fromFlexform   = $this->settings['flexform']['myField'];
    
    // or...
    $myMergedSetting = (!$this->settings['flexform']['myField'])
                       ? $this->settings['myField']
                       : $this->settings['flexform']['myField'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算