2016-06-09 36 views
0

我有一个Extbase扩展工作区,它向前端显示一个表单,具体取决于后端在页面中选择了哪些选项。在常量管理器中使常量可用

我对这些选项使用Flexform(主要是表单动作,但也包括一些字段)。

一切工作正常,除了常数。 由于此表单模板可能会针对不同网站进行更改,因此我希望能够更改模板根路径,以便我可以定义自定义模板。

我有一个constants.txt和form_plugin /配置一个SETUP.TXT/Typo脚本

常数是这样的:

plugin.tx_nlmymail_newsletter { 
    view { 
     # cat=plugin.tx_nlmymail_newsletter/file; type=string; label=Path to template root (FE) 
     templateRootPath = EXT:nl_mymail/Resources/Private/Templates/ 
     # cat=plugin.tx_nlmymail_newsletter/file; type=string; label=Path to template partials (FE) 
     partialRootPath = EXT:nl_mymail/Resources/Private/Partials/ 
     # cat=plugin.tx_nlmymail_newsletter/file; type=string; label=Path to template layouts (FE) 
     layoutRootPath = EXT:nl_mymail/Resources/Private/Layouts/ 
    } 
    persistence { 
     # cat=plugin.tx_nlmymail_newsletter//a; type=string; label=Default storage PID 
     storagePid = 
    } 
} 

我SETUP.TXT看起来是这样的:

plugin.tx_nlmymail_newsletter { 
    view { 
     templateRootPaths.0 = {$plugin.tx_nlmymail_newsletter.view.templateRootPath} 
     partialRootPaths.0 = {$plugin.tx_nlmymail_newsletter.view.partialRootPath} 
     layoutRootPaths.0 = {$plugin.tx_nlmymail_newsletter.view.layoutRootPath} 
    } 
    persistence { 
     storagePid = {$plugin.tx_nlmymail_newsletter.persistence.storagePid} 
    } 
} 

所以根据this,这应该是足够的。 也许我在这里错过了一件。

在我ext_tables.php我使用

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'mail connection'); 

要包括Typo脚本。

我是否需要为我的常量创建自定义类别?

我与bootstrap_package插件相比,但我似乎无法找到关键的区别。

如果有人能指出我正确的方向,也许是我失踪的文档的一部分,我会非常感激。

+1

您是否通过模板包含静态文件?如果是的话,那么我会看到一个有趣的事情:为什么你在你的例子中有这样的一次:form_plugin/Configuration/TypoScript和一次plugin.tx_nlmymail_newsletter?他们是一样的吗? 代码自我看起来很好。 –

+0

是的,那是一个复制错误。你的意思是什么“用模板包含你的静态文件”? – Eupides

+0

他意味着你应该从你的根模板http://screencast.com/t/kBRp8Y5G1添加静态模板,你也可以设置“设置”变量,所以你可以从你的控制器得到它像$ this-> settings –

回答

1

从意见复制:

问题是静态模板未包含在模板中。

下面是截图:

enter image description here

是否pissible这么自动做?

是的,它只是基于字符串的函数而不是文件。

你必须使用你的ext_localconf.php以下命令:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('TYPO3.CMS.Felogin', 'constants', ' 
styles.content.loginform { 
    # cat=content/cLogin; type=int+; label= PID of user archive: Enter the page-uid number (PID) of the folder where you keep your fe_users that are supposed to login on this site. This setting is necessary, if login is going to work! 
    pid = 
    # cat=content/cLogin; type=; label= Login template: Enter the path for the HTML template to be used 
    templateFile = EXT:felogin/Resources/Private/Templates/FrontendLogin.html 
} 
', 'defaultContentRendering'); 

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('TYPO3.CMS.Felogin', 'setup', ' 
# Setting "felogin" plugin TypoScript 
tt_content.login = COA 
tt_content.login { 
    10 =< lib.stdheader 
    20 > 
    20 =< plugin.tx_felogin_pi1 
} 
', 'defaultContentRendering'); 

最后:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript 

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants 
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup 

从felogin系统扩展示例

建议使用静态模板,因为您可能有不同的树和设置。大多数TER扩展也使用这种方法。