php - Typoscript 和访问 $this->settings 的 TYPO3 问题

标签 php typo3 typoscript

我使用的是 TYPO3 版本 7.6.14,我为客户端创建了一个扩展,它有四个 Controller 、四个插件,而且它的整体相当大。无论如何,现在我需要为动态或用户选择的“页面 ID”添加选项(设置变量),然后用于从一个插件重定向到另一个。可能有更好的解决方案来解决我的问题,但我正在尝试做类似的事情:

plugin.tx_extname_basket {
    view {
        # cat=plugin.tx_extname_basket/file; type=string; label=Path to template root (FE)
        templateRootPath = EXT:extname/Resources/Private/Templates/
        # cat=plugin.tx_extname_basket/file; type=string; label=Path to template partials (FE)
        partialRootPath = EXT:extname/Resources/Private/Partials/
        # cat=plugin.tx_extname_basket/file; type=string; label=Path to template layouts (FE)
        layoutRootPath = EXT:extname/Resources/Private/Layouts/
    }
    persistence {
        # cat=plugin.tx_extname_basket//a; type=string; label=Default storage PID
        #storagePid =
    }
    settings {
        #  cat=plugin.tx_extname_basket//a; type=int; label=Products Page ID
        productsPage =
    }
}

现在的问题是,即使我 100% 确定 Typoscript 已正确包含在加载扩展的页面中,变量 $this->settings['productsPage'] 和 FLUID {settings.productsPage} 不起作用。我清除了整个缓存,甚至尝试删除整个 typo3temp 文件夹,但它仍然不起作用。我还尝试调试 $this 对象,它显示 settings => NULL

Image from objects browser

哦,productsPage 是在“SETUP”下的默认根模板中输入的,当浏览 Typoscript 对象(在管理中)时,我可以看到设置设置得很好。所以我不认为我有无效的 TypoScript。

最佳答案

如果您有四个插件,则必须为每个插件设置此 Typoscript 设置。如果您上面的 Typoscript 正确包含,“设置”将只能用于插件“篮子”。

另一件事:您的 Typoscript 中的注释似乎这些设置是 Typoscript 常量而不是 Typoscript 设置。在设置中,您还必须将这些常量传递给插件配置。示例:

plugin.tx_extname_basket {
    settings {
        productsPage = {$plugin.tx_extname_basket.settings.productsPage}
    }
}

您还必须将模板等的其他常量传递给设置。

关于php - Typoscript 和访问 $this->settings 的 TYPO3 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41157986/

相关文章:

typo3 - 如何在 TSConfig addToList 中使用多行代替线性列表?

javascript - 如何在自己的 Typo3 6.2 扩展中包含 .js 文件?

php - cakephp - 使用多词搜索字符串构建查询,搜索多个字段

php - "Inactive Wrapper"创建大量空白

php - 在 PHP 上解析来自 base64 的 csv 文件

typo3 - 发送TYPO3 EXT :powermail mail to different receivers depending on selection in a dropdown

TYPO3 Extbase : How to get disabled related Object, 没有原始 sql 查询?

css - TYPO3 禁用用户组的图标

mysql - TYPO3 MySQL 选择查询,在 phpMyAdmin 中有效,但在 TYPO3 中无效

php - 没有地理编码的我的位置