5

我想一旦你知道它就很简单,但我现在正在搜索这个主题超过 4 小时。所以也许有人可以帮助我,推动正确的方向。

我用 Extbase 为 TYPO3 6.2 开发了一个扩展。插件配置是使用 FlexForm 完成的。为了提高可用性,我想在我的 FlexForm 中添加工具提示(帮助文本或 CSH)。

方法1: 我用标签尝试过

<cshFile>

并将相应的 XML 添加到扩展文件中。正如许多论坛和博客所建议的那样,这已被弃用,所以我坚持让我们尝试另一种方法。

方法 2: 将“locallang_csh_flexforms.xml”添加到 ext_tables.php 中的插件。这似乎更合乎逻辑,也建议作为新的方法来做到这一点。此方法也以某种方式被 tx_news 扩展使用,该扩展总体上具有可靠的代码。

但是,这似乎对我不起作用,我尝试替换所有已弃用的类(由 tx_news 使用)并将实现克隆到我的插件中。显示了 FlexForm,但仍然没有可用的工具提示。我现在将发布一些我当前状态的代码片段。它试图做“tx_news”中所做的事情。

这些是我最常使用的文件,如果我没有忘记的话。如果还有其他感兴趣的,请告诉我,我会添加它。

tx_news 中的功能 在此处输入图像描述

ext_tables.php

if (!defined('TYPO3_MODE')) {
    die ('Access denied.');
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
    'tt_content.pi_flexform.psc_disqus_sso_sso.list', 'EXT:' . $_EXTKEY . '/Resources    /Private/Language/locallang_csh_flexforms.xml');

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    $_EXTKEY,
    'Sso',
    'Psc Disqus'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY,     'Configuration/TypoScript', 'Psc Disqus SSO');

//flexforms
$extensionName = \TYPO3\CMS\Core\Utility    \GeneralUtility::underscoredToUpperCamelCase($_EXTKEY);
$pluginSignature = strtolower($extensionName) . '_sso';

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout,recursive,select_key,pages';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] =     'pi_flexform';

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature,     'FILE:EXT:'.$_EXTKEY.'/Configuration/FlexForms/SsoSession.xml');

locallang_csh_flexforms.xml

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
    <description>CSH for flexforms</description>
    <type>CSH</type>
    <fileId>EXT:psc_disqus_sso/locallang_csh_flexforms.xml</fileId>
    <labelContext type="array"></labelContext>
</meta>
<data type="array">
    <languageKey index="default" type="array">
        <label index="settings.useSSO.description">Check to Use SSO Functionality</label>

        <label index="settings.disqus.general.shortName.description">Tells the Disqus service your forum's shortname, which is the unique identifier for your website as registered on Disqus. If undefined, the Disqus embed will not load.</label>
        <label index="settings.disqus.general.title.description">Tells the Disqus service the title of the current page. This is used when creating the thread on Disqus for the first time. If undefined, Disqus will use the <title> attribute of the page. If that attribute could not be used, Disqus will use the URL of the page.</label>
        <label index="settings.disqus.general.categoryId.description">Tells the Disqus service the category to be used for the current page. This is used when creating the thread on Disqus for the first time.</label>
        <label index="settings.disqus.general.disableMobile.description">Tells the Disqus service to never use the mobile optimized version of Disqus.</label>

...(just some more labels and closing tags)...

SsoSession.xml

<T3DataStructure>
<meta>
    <langDisable>1</langDisable>
</meta>
 <sheets>
  <sDEF>
   <ROOT>
     <TCEforms>
        <sheetTitle>SSO Settings</sheetTitle>
     </TCEforms>
     <type>array</type>
     <el>
        <settings.useSSO>
            <TCEforms>
                <label>Activate Disqus Single Sign On</label>
                <config>
                    <type>check</type>
                </config>
                <onChange>reload</onChange>
            </TCEforms>      
        </settings.useSSO>
         <settings.disqus.sso.name>
            <TCEforms>
                <label>Website name (Your site's name. Disqus will display it in the Post As window.)</label>
                <config>
                    <type>input</type>
                    <size>30</size>
                    <default>Website</default>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.name>
        <settings.disqus.sso.loginButton>
            <TCEforms>
                <label>Login Button (optional)</label>
                <config>
                    <type>group</type>
                    <internal_type>file</internal_type>
                    <allowed>jpg,gif,png</allowed>
                    <max_size>2000</max_size>
                    <uploadfolder>uploads/tx_pscdisqussso/loginButton</uploadfolder>
                    <show_thumbs>1</show_thumbs>
                    <size>1</size>
                    <minitems>0</minitems>
                    <maxitems>1</maxitems>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.loginButton>
        <settings.disqus.sso.favIcon>
            <TCEforms>
                <label>Icon (optional)</label>
                <config>
                    <type>group</type>
                    <internal_type>file</internal_type>
                    <allowed>jpg,gif,png</allowed>
                    <max_size>2000</max_size>
                    <uploadfolder>uploads/tx_pscdisqussso/loginButton</uploadfolder>
                    <show_thumbs>1</show_thumbs>
                    <size>1</size>
                    <minitems>0</minitems>
                    <maxitems>1</maxitems>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.favIcon>
        <settings.disqus.sso.loginPage>
            <TCEforms>
                <label>Login Page</label>
                <config>
                    <type>group</type>
                    <internal_type>db</internal_type>
                    <allowed>pages</allowed>
                    <size>1</size>
                    <maxitems>1</maxitems>
                    <minitems>0</minitems>
                    <show_thumbs>1</show_thumbs>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.loginPage>
        <settings.disqus.sso.loginHeight>
            <TCEforms>
                <label>Login Window Height</label>
                <config>
                    <type>input</type>
                    <size>20</size>
                    <max>30</max>
                    <default>800</default>
                    <eval>int</eval>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.loginHeight>
        <settings.disqus.sso.loginWidth>
            <TCEforms>
                <label>Login Window Width</label>
                <config>
                    <type>input</type>
                    <size>20</size>
                    <max>30</max>
                    <default>400</default>
                    <eval>int</eval>
                </config>
                <displayCond>FIELD:settings.useSSO:REQ:true</displayCond>
            </TCEforms>      
        </settings.disqus.sso.loginWidth>
     </el>
   </ROOT>
  </sDEF>
  <disqusConfigurationGeneral>
   <ROOT>
     <TCEforms>
      <sheetTitle>Disqus Settings</sheetTitle>
     </TCEforms>
     <type>array</type>
     <el>
        <settings.disqus.general.shortName>
            <TCEforms>
                <label>Disqus Shortname</label>
                <config>
                    <type>input</type>
                    <size>30</size>
                    <eval>required</eval>
                </config>
            </TCEforms>      
        </settings.disqus.general.shortName>
        <settings.disqus.general.title>
            <TCEforms>
                <label>Title (Tells the Disqus service the title of the current page. This is used when creating the thread on Disqus for the first time. If undefined, Disqus will use the &lt;title&gt; attribute of the page. If that attribute could not be used, Disqus will use the URL of the page.)</label>
                <config>
                    <type>input</type>
                    <size>30</size>
                </config>
            </TCEforms>      
        </settings.disqus.general.title>
        <settings.disqus.general.categoryId>
            <TCEforms>
                <label>Disqus Category (see documentation)</label>
                <config>
                    <type>input</type>
                    <size>30</size>
                </config>
            </TCEforms>      
        </settings.disqus.general.categoryId>
        <settings.disqus.general.disableMobile>
            <TCEforms>
                <label>Disable Disqus Mobile Optimization (see documentation)</label>
                <config>
                    <type>check</type>
                </config>
            </TCEforms>      
        </settings.disqus.general.disableMobile>
        <settings.disqus.general.disableMobile>
            <TCEforms>
                <label>Disable Disqus Mobile Optimization (see documentation)</label>
                <config>
                    <type>check</type>
                </config>
            </TCEforms>
        </settings.disqus.general.disableMobile>
     </el>
   </ROOT>
  </disqusConfigurationGeneral>
 </sheets>
</T3DataStructure>
4

1 回答 1

9

这很容易......但在这种情况下,TYPO3 6.2 的缓存可能会非常烦人

  1. 假设您有一个带有键my_extensionBar插件的扩展, ext_tables.php中常见的flexform包含如下所示:

    $pluginSignature = str_replace('_','',$_EXTKEY) . '_bar'; // which gives `myextension_bar`
    $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_bar.xml');
    
  2. 例如,为 CSH 创建文件(名称无关紧要,反正按照惯例...):

    typo3conf/ext/my_extension/Resources/Private/Language/locallang_csh_flexform_bar.xlf
    
  3. 使用正确的 (!)键在ext_tables.php中添加对此 locallang 的引用

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr(
        'tt_content.pi_flexform.myextension_bar.list',
        'EXT:my_extension/Resources/Private/Language/locallang_csh_flexform_bar.xlf'
    );
    
  4. 最重要的打开安装工具,转到重要操作并单击清除所有缓存

  5. 就是这样:您的 CSH 现在应该可以工作了,如果它不检查 locallang ( tt_content.pi_flexform...) 的键是否有效,还检查Configuration > $GLOBALS['TCA_DESCR']如果它在那里列出(如果没有清除缓存表单再次安装工具)

示例locallang_csh_flexform_bar.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" datatype="plaintext" original="messages" date="2014-05-28T07:44:03Z" product-name="my_extension">
        <header/>
        <body>
            <trans-unit id="settings.disqus.sso.name.description">
                <source>Your site's name. Disqus will display it in the Post As window.</source>
            </trans-unit>
        </body>
    </file>
</xliff>
于 2014-06-14T09:00:11.923 回答